Archive: Copying Files from CD


Copying Files from CD
In NSIS, is there any way to get the drive letter of a CD by searching for its CD name, and then access the files on the CD?

Would I use this?

http://nsis.sourceforge.net/CDRom_plug-in

If so, what commands would I use to get the drive letter of the CD whose name is "Bob_1"?

How would I copy files over from that drive letter to the $INSTDIR?

Thanks.


http://nsis.sourceforge.net/Docs/AppendixE.html#E.1.5


Sorry, Red Wine, but I don't think that it talks about searching for the name of the CD. It only tells me how to search for a type of media storage device, and drive letter.

Could you tell me how to find the drive letter of a CD by entering the NAME of the CD I'm searching for?

Many thanks!

Could you also show me how to implement it directly into an installation code file?


GetDrives has the option to find CD drives only and returns the corresponding drive letter for each drive.
I think instead of volume name you could add a file on the root of the media e.g. cdid and look for this file, e.g.

Section
${GetDrives} "CDROM" "Example1"
CopyFiles "$R0\my_file.ext" "$INSTDIR\my_file.ext"
SectionEnd

Function Example1
MessageBox MB_OK "$9 ($8 Drive)"
IfFileExists "$9\cdid" 0 next
StrCpy $R0 "$9" ;$R0 contains the drive you're looking
StrCpy $0 "StopGetDrives"
next:
Push $0
FunctionEnd

Sorry, but how would I replace IfFileExists "$9\cdid" with multiple files? (so I can make the search more accurate)

I tried &&, but it doesn't work.

Sorry, I'm kind of new to NSIS.

Thanks.


You just need to add a unique file on media root that identifies the cd, that's all, just create an empty text file and rename it as cdid and you're done.
Multiple IfFileExists could be easily done with logiclib e.g.
${If} {FileExists} "file1.ext"
${AndIf} {FileExists} "file2.ext"
${AndIf} {FileExists} "file3.ext"
........


I did this:

Function Example1
MessageBox MB_OK "$9 ($8 Drive)"
${If} {FileExists} "$9\file1.exe"
${AndIf} {FileExists} "$9\file2.exe" 0 next
StrCpy $R0 "$9" ;$R0 contains the drive you're looking
StrCpy $0 "StopGetDrives"
next:
Push $0
FunctionEnd

(And I also included !include "LogicLib.nsh")

It gave me this:

Function: "Example1"
MessageBox: 0: "$9 ($8 Drive)"
!insertmacro: _If
!insertmacro: macro "_If" requires 4 parameter(s), passed 3!

And then aborted.


Gosh! did you first examine the included logiclib example?

Function Example1
MessageBox MB_OK "$9 ($8 Drive)"
${If} ${FileExists} "$9\file1.exe"
${AndIf} ${FileExists} "$9\file2.exe"
StrCpy $R0 "$9" ;$R0 contains the drive you're looking
StrCpy $0 "StopGetDrives"
${EndIf}
Push $0
FunctionEnd

Thanks.

But I had to put a dollar sign in front of "file exists"


that's true, didn't see my typo.


No problem. Thanks for your help.