ZonaNet Blog: Running WPI
ZonaNet Blog Home Page

MAIN MENU
SEARCH
BLOGGER

Google

POLL
Are You ZonaNet Blog Visitor?
Always
Sometimes
Never

     



eXTReMe Tracker

 
Running WPI
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.INF:
[autorun]open=autorun.exe -q2 -w -x wpi\WPI.hta
cleanup.exeicon=wpi.ico






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:






Path=%windir%\
TempSetup=RunWPI.exe
Silent=1Overwrite=1
Title=Extracting
files...


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:


RunWPI.au3:
AutoItSetOption("TrayIconHide",
1)
AutoItSetOption("WinTitleMatchMode", 4)
BlockInput(1)


SplashTextOn("", "" & @CRLF & "Preparing
post-installation..." & @CRLF & "" & @CRLF & "Please wait..."
& @CRLF & "", 320, 90, -1, -1, 1, "Arial", 12,
12)
Sleep(3000)SplashOff()
Run("RunWPI.cmd", "", @SW_HIDE)
Exit



RunWPI.cmd:
@echo off
::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
CDROM=%%d

::Run WPI...autorun.exe -q2 -w -x %cdrom%\wpi\WPI.hta
%cdrom%\cleanup.exe %cdrom%\rename.exe
%cdrom%\restart.exe
CLS
EXIT


The following files are placed at the root of the CD to perform post-WPI
operations:

A compiled Cleanup.au3 AutoIt
script:
AutoItSetOption("TrayIconHide",
1)
AutoItSetOption("WinTitleMatchMode", 4)
BlockInput(1)
Run(
@ScriptDir & "\cleanup.cmd", "", @SW_HIDE)

Exit

A corresponding Cleanup.cmd batch file:
@echo off
RD /S /Q "%systemdrive%\Drivers"
ECHO Y Del
"%systemdrive%\WINDOWS\*.bmp"
ECHO Del "%systemdrive%\*.log"
DEL
/F "%systemdrive%\Documents and Settings\All Users\Start
Menu\Programs\Startup\Run_WPI.exe"
@Rmdir %systemdrive%\TEMP /s/q
@mkdir
%systemdrive%\TEMP
@Rmdir %systemdrive%\WINDOWS\TEMP /s/q
@mkdir
%systemdrive%\WINDOWS\TEMP
CLS
EXIT


A compiled Rename.au3 AutoIt script:
AutoItSetOption("TrayIconHide",
1)
AutoItSetOption("WinTitleMatchMode",
4)
BlockInput(1)
Send("#r")
WinWaitActive
("Run")
Send("sysdm.cpl{Enter}")
WinWaitActive("System
Properties")
Send("{TAB 3}")
Send("{RIGHT
1}")
Send("!c")
Send("{BACKSPACE}")
BlockInput(0)
MsgBox(0, "Rename
PC", "Please rename this machine.")
WinWaitActive("Computer Name Changes",
"You must restart this
computer")
BlockInput(1)
Send("{ENTER}")
WinWaitActive("System
Properties")
Send("{ENTER}")
WinWaitActive("System Settings
Change")
Send("!n")
Exit


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.

Labels:

posted by ZonaNet @ 1:57 PM  
0Comments:
Post a Comment
Home
 
About Me

Name: Yazin Alhamdi
Country: LIBYA
About Me: Angel!
Email: yazin.alhamdi@gmail.com
My Guest Book
Previous Post
Archives
Links
Powered by

BLOGGER

© ZonaNet Blog Template by ZonaNet