Skip to content
⌘ NSIS Forum Archive

Check for CD Volume

10 posts

gruntlord6#

Check for CD Volume

Hey everyone. I'm working on a project where I need to modify my existing installer to provide the option of copying some files from the original installation CD instead of downloading them. I did find the NSIS CDROM plugin but I'm not exactly sure what I should be doing with it to achieve my goal.

In essence, the plugin would:
1. Probe for the next cd/dvd drive
2. check for the CD volume label "PRODUCT1", if it is not found repeat step 1
3. Copy the "DATA" directory from the volume to the install directory

Obviously the last part is pretty simple, but I'm not sure what I should be doing to achieve parts 1 and 2. Any help is appreciated.
gruntlord6#
Originally Posted by Yathosho View Post
Have a look at the CD-ROM plug-in
Like I said in my post I'm aware of the plugin but the example didn't help clarify it's usage in my case. Do you perhaps have an example?
JasonFriday13#
I've noticed that several of my older multi CD games don't require physical media to install, just dumping all the files into one directory is enough for it to install correctly (running it is a different story).

I know you have found my WimImage plugin (with multi-disc tweaks), and all I use to check for the next file is an IfFileExists call in a loop, and it displays a message box if not found. So, storing the files in an archive (zip, 7z, wim) and checking for a single file is quite a bit easier to implement.

Here's a couple of un-archiver plugins (I used to use zipdll, now I use my own plugin):





WimImage is also good, although it requires Windows 7 and up which is not great for Vista and earlier users.
aerDNA#
This should do what OP wants:

OutFile "CDCheck.exe"
!include "FileFunc.nsh"
!define CDLabel "PRODUCT1"

Function .onInit
StrCpy $R9 ""
${GetDrives} "CDROM" "CDCheck"
StrCmp $R9 "StopGetDrives" 0 +2
MessageBox MB_OK|MB_ICONINFORMATION "Volume ${CDLabel} is mounted as $R2" IDOK +2
MessageBox MB_OK|MB_ICONEXCLAMATION "Volume ${CDLabel} not found."
Abort
FunctionEnd

Function CDCheck
System::Call 'Kernel32::GetVolumeInformation(t r9, t.R1, i ${NSIS_MAX_STRLEN},,,,,) i.R0'
StrCmp $R0 0 CDCheck_Return
StrCmp $R1 ${CDLabel} 0 CDCheck_Return
StrCpy $R2 $9
StrCpy $R9 "StopGetDrives"
CDCheck_Return:
Push $R9
FunctionEnd

Section Blank
SectionEnd
Collector9999#
But not all CD have a volume label. Often you have to ID a disc by other means, such as searching for a specific file on the disc.
JasonFriday13#
That's the reason that older multi-disc installs work when dumped into a folder, because they only check for the required files, not volume labels.
gruntlord6#
Originally Posted by Collector9999 View Post
But not all CD have a volume label. Often you have to ID a disc by other means, such as searching for a specific file on the disc.
If it's the right disk it would always have that as the volume label.

Basically, you guys are saying I should just check if the files are in the proper structure on the disk?
JasonFriday13#
Yes, because that way you can put the entire install in a folder for initial testing, and move to .iso and a virtual disc drive for actual testing. I haven't tested WimImage on a virtual drive yet, but it should work as the source path doesn't change.