Wednesday, June 27, 2007
|It became apparent that WPI would be useful not only during a full unattended Windows XP installation but also as a stand-alone application to selectively install programs on a pre-configured machine. As a stand-alone app, it would need to start automatically when inserted into the CD-ROM drive. The problem, however, is that standard autorun functionality supports executable files only and not others such as .cmd or .hta.
Enter TARMA SOFTWARE RESEARCH, the creators of AutoRun, a freeware application that supports multiple file types. Placing Tarma's AutoRun executable at the root of the CD togther with a custom .inf file calls WPI when the CD is inserted: AUTORUN.INF:
[autorun]open=autorun.exe -q2 -w -x wpi\WPI.hta
AutoRun's versatility extends beyond simple .inf installs. For example, it can be called from the hard drive to run, in turn, the WPI .hta, batch files, and compiled AutoIt scripts. My hard drive install routine runs WPI and then performs a cleanup operation before allowing me to alter the machine name and workgroup information. Once uniquely named, the CD is ejected and the machine reboots. The routine is a tad convoluted, like so:
A WinRAR SFX called Run_WPI.exe is placed in the $OEM$ Startup directory and copied over to the hard drive during the OEM install with the following comment:
Run_WPI.exe holds the files AutoRun.exe, RunWPI.exe, and RunWPI.cmd. It is sparked upon first boot and fires up a compiled AutoIt script from the Temp directory called RunWPI.exe. RunWPI.exe hides completely a batch file that, together with Tarma's AutoRun, performs the actual install:
SplashTextOn("", "" & @CRLF & "Preparing
post-installation..." & @CRLF & "" & @CRLF & "Please wait..."
& @CRLF & "", 320, 90, -1, -1, 1, "Arial", 12,
Run("RunWPI.cmd", "", @SW_HIDE)
::Locate the CDROM drive if necessary,
where AUTORUN.INF exists at the root...FOR %%d IN (c: 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 %%d\AUTORUN.INF SET
::Run WPI...autorun.exe -q2 -w -x %cdrom%\wpi\WPI.hta
The following files are placed at the root of the CD to perform post-WPI
A compiled Cleanup.au3 AutoIt
@ScriptDir & "\cleanup.cmd", "", @SW_HIDE)
A corresponding Cleanup.cmd batch file:
RD /S /Q "%systemdrive%\Drivers"
ECHO Y Del
ECHO Del "%systemdrive%\*.log"
/F "%systemdrive%\Documents and Settings\All Users\Start
@Rmdir %systemdrive%\TEMP /s/q
@Rmdir %systemdrive%\WINDOWS\TEMP /s/q
A compiled Rename.au3 AutoIt script:
PC", "Please rename this machine.")
WinWaitActive("Computer Name Changes",
"You must restart this
The author chose to call batch files from AutoIt scripts to hide their activity instead of using the "cmdow @ /HID" convention. Although useful, cmdow.exe nonetheless produces a command window momentarily, whereas AutoIt's "@SW_HIDE" parameter flag hides the window completely.