Archive: Copy from USB or CD (any letter of the driver)


Copy from USB or CD (any letter of the driver)
I created an application that I must distribute with CD or USB. I need to copy files from USB or CD to C: \ "foo" on different computers. You know that the driver can change letter (D, E, F and so on ...): What scripts I need to use to copy from a CD or USB (any letter) to C: \ "foo"?
Thanks.


The easiest solution would simply be to enumerate all drives and check for an identifying mark, such as specific path/filenames and/or volume label. You can use the DVD_GetNextDrive function from http://nsis.sourceforge.net/DVD_functions

But you'll need to modify it to scan for other drive types as well. Particularly, change:

      ;get type of drive
System::Call 'kernel32::GetDriveType(t "$R2:\") i .r13'
StrCmp $R3 5 0 NoDriveHere
;if type is CDROM

into:
      ;get type of drive
System::Call 'kernel32::GetDriveType(t "$R2:\") i .r13'
StrCmp $R3 2 +2 0
StrCmp $R3 5 0 NoDriveHere
;if type is CDROM or REMOVABLE

If your executable is on the CD/USB then just use $EXEDIR.

Stu


D'oh. Well spotted. :igor:


You must use $EXEDIR for thing like these, not just because it is easy but because a volume can be mounted in a directory (NT5+), ex: c:\foo\bar\myusbdrive\yoursetup.exe