Unattended XPCD
   


RunOnceEx from CD
Submitted by Unknown

Some of our readers wanted a way to install their software from the CD without copying the files to the Hard Drive using the \$OEM$\$1\ folders. This guide will show you a simple way on how you can accomplish this without needing to use third-party utilities.

Please make sure you have read through the RunOnceEx guide first!

» Making modifications to your existing RunOnceEx.cmd file

In order to find the correct CD drive letter, we need to include some IF EXIST statements in the RunOnceEx.cmd file. Open RunOnceEx.cmd in Notepad, and include the following after @echo off:

FOR %%i IN (D E F G H I J K L M N O P Q R S T U V W X Y Z) DO IF EXIST %%i:\CD.txt SET CDROM=%%i:

Create a blank text file called CD.txt and place this in the root of your Windows Setup Source folder. This allows the IF EXIST command to scan all the drive letters specified, then when it finds CD.txt it will set an environment variable of %CDROM% pointing to the correct drive letter.

Alternatively, you can use the following code to set the %CDROM% variable if you wish to not be bothered by the CD.txt file requirements, or the inefficiency of checking every drive for a specific file, used of the previous method.
SetLocal enableextensions
SET CDROM=%~d0

It works by setting the %CDROM% variable to the same drive on which the script resides. In this case, the script being the actual RunOnceEx.cmd file. Just make sure you also include
EndLocal
before the EXIT line, to close the extension. Keep in mind, when the extension is closed, the %CDROM% variable will be reset. For consistency, this guide will use the first method, but both are working solutions.

The next thing to do is take all your software out of \$OEM$\$1\install\, and put it in \Software\ or a folder name of your choice.

Going back to the RunOnceEx.cmd file, we'll need to make further changes:
  • Change all instances of %systemdrive% to %CDROM%
  • Fix all the paths to the software installation file, i.e. "%CDROM%\Software\MSN_Messenger.msi /qn"
That's all you need to do! RunOnceEx.cmd will scan for the correct drive letter where your CD is in, sets that drive letter to the %CDROM% environment variable, and the drive letter will be imported to the registry. Give it a go and see for yourself! The end result should look something like this:

cmdow @ /HID
@echo off

FOR %%i IN (D E F G H I J K L M N O P Q R S T U V W X Y Z) DO IF EXIST %%i:\CD.txt SET CDROM=%%i:

SET KEY=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx

REG ADD %KEY% /V TITLE /D "Installing Applications" /f

REG ADD %KEY%\001 /VE /D "Preparing Installation..." /f
REG ADD %KEY%\001 /V 1 /D "%CDROM%\Software\prepare.cmd" /f

REG ADD %KEY%\015 /VE /D "Alcohol 120 Percent" /f
REG ADD %KEY%\015 /V 1 /D "%CDROM%\Software\alcohol\setup.exe /qn Reboot=Suppress" /f
REG ADD %KEY%\015 /V 2 /D "REGEDIT /S %CDROM%\Software\alcohol\register.reg" /f

REG ADD %KEY%\025 /VE /D "Diskeeper 8.0.478" /f
REG ADD %KEY%\025 /V 1 /D "%CDROM%\Software\Diskeeper\DiskeeperPro_8.0.478.exe /s /v/qn" /f

EXIT

Unattended XPCD


» Other things to keep in mind

The %CDROM% environment variable isn't permanent, and only lasts during the session of when the cmd file is ran. Since we have the FOR statement and the REG ADD entries in one single cmd file, there is nothing else to worry about. However, if you run another different cmd file that accesses a file on the CD, you should include the FOR statement in that cmd file as well.

Should you need a permanent environment variable, consider using an utility such as DetectCD.exe or setenv.exe.
Last updated 2006-01-09 14:31:37 by Unknown  [Edit]
All trademarks mentioned on this page are the property of their respective owners
MSFN is not affiliated with Microsoft
Copyright © 2001 - 2013 msfn.org
Privacy Policy