John 777
24th January 2012 10:06 UTC
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.
MSG
24th January 2012 10:19 UTC
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
Afrow UK
24th January 2012 11:20 UTC
If your executable is on the CD/USB then just use $EXEDIR.
Stu
MSG
24th January 2012 11:26 UTC
D'oh. Well spotted. :igor:
Anders
25th January 2012 23:13 UTC
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