OK, as promised, here is my code BEFORE I started using Kickarse's scan tool, so this code includes my own scanning routine. Make sure C:\DP exists, and EXTRACT the packs you want to work with to that folder. This code is AS-IS, so if you run the installer (justinstall_s 2.au3) it WILL DELETE the C:\DP folder when done, so comment out line 194 to prevent this.
My INF scanner: (justscan.au3)
TrayTip("generating databases", "please wait a moment", 150, 1)
#include<process.au3>
$rc=_rundos("dir /s c:\dp\*.inf >c:\dp\allinf.txt")
global $hwcount
global $hwgo
global $dirty
global $infcount
global $infcount2
global $gobatcount
global $trips
global $slashcount
global $strlength
global $ampcount
sleep(2000)
$allinf = FileOpen("c:\dp\allinf.txt", 0)
FileOpen("c:\dp\masterinflist.txt", 1)
Do
$linein = FileReadLine($allinf)
If @error = -1 Then ExitLoop
$lookfordir = StringInStr($linein, "Directory of")
if $lookfordir<>0 Then
$len=StringLen ($linein)
$dirname=StringRight ( $linein, $len-14)
EndIf
$lookforinf = StringInStr($linein, ".inf")
if $lookforinf<>0 Then
$len=StringLen ($linein)
$infname=StringRight ( $linein, $len-39)
FileWriteLine ("c:\dp\masterinflist.txt", $dirname & "\" & $infname)
$infcount2=$infcount2+1
EndIf
until 1=2
FileClose($allinf)
FileClose("c:\dp\masterinflist.txt")
;start section where INFs are scanned for HWIDs
$mastinf=FileOpen("c:\dp\masterinflist.txt", 0)
FileOpen("c:\dp\masterhwid.txt", 1)
Do
$hwidin = FileReadLine($mastinf)
If @error = -1 Then ExitLoop
$wroteone=0
$infcount=$infcount+1
$openinf=$hwidin
$currentinf=FileOpen($openinf, 0)
TrayTip("scanning inf " & $infcount & " of " & $infcount2 , $openinf, 15, 1)
Do
$infin = FileReadLine($currentinf)
If @error = -1 Then ExitLoop
$lookforperc = StringLeft($infin,1)
if $lookforperc="%" Then
$dirty=0
if StringLeft($infin,1)=";" then $dirty=1
if $dirty=0 then
$infout=$infin
$len222=stringlen($infin)
for $n=1 to $len222
$whatis=stringmid($infin,$n,1)
if $whatis="\" Then
$leftcount=$n
$rightcount=$n
Do
$findleft=stringmid($infin,$leftcount,1)
if $findleft=" " then ExitLoop
$leftcount=$leftcount-1
until $leftcount<0
Do
$findright=stringmid($infin,$rightcount,1)
if $findright=" " then ExitLoop
$rightcount=$rightcount+1
until $rightcount>$len222
$infout=stringstripws(stringmid($infin,$leftcount,$rightcount-$leftcount),8)
EndIf
Next
endIf
if $dirty="0" and $infout<>"" then
FileWriteLine ("c:\dp\masterhwid.txt", $infout)
$wroteone=1
endif
EndIf
until 1=2
if $wroteone=1 then FileWriteLine ("c:\dp\masterhwid.txt", "********" & $hwidin)
FileClose($openinf)
FileClose($currentinf)
until 1=2
FileClose("c:\dp\masterhwid.txt")
FileClose($mastinf)
FileDelete("c:\dp\allinf.txt")
Fileclose("c:\dp\masterinflist.txt")
FileDelete("c:\dp\masterinflist.txt")
TrayTip("finished ", "done scanning",15,1)
Exit
Main install app (justinstall_s 2.au3) (named "_s 2" for SysPrep-tailored version, version 2)
; Hands-Off Driver Installer v1.2 3/2/2009
; by Ian Maxwell
; llewxamnai@gmail.com
;
; Make sure you have drivers extracted to C:\DP (subfolders from there are fine), devcon.exe in
; C:\DP, and dpinst.exe and dpinst.xml in C:\DP\INST. Layout of dpinst.xml should be:
;
; <?xml version="1.0" ?>
; <dpinst>
; <search>
; <subDirectory>*</subDirectory>
; </search>
; <scanHardware/>
; <legacyMode/>
; </dpinst>
;
; Also have a file called inst.cmd in C:\DP\INST with the following lines:
;
; @echo off
; title Driver Installer
; c:\dp\inst\dpinst.exe /SW /C /S /SA
run("c:\windows\system32\suppress.exe")
SplashTextOn("auto driver loader stage 1/7","generating databases",-1,50)
#include<process.au3>
$rc=_rundos("c:\dp\devcon.exe hwids * >c:\dp\hwids.txt")
global $hwcount
global $hwgo
global $dirty
global $infcount
global $infcount2
global $gobatcount
global $trips
global $slashcount
global $strlength
global $ampcount
;global $hwidcount ;only include if needed, runs much slower with this on
;strip out unneeded info from hwids.txt
$id=FileOpen("c:\dp\hwids.txt",0)
FileOpen("c:\dp\hwidlist.txt",1)
Do
$idinraw = FileReadLine($id)
If @error = -1 Then ExitLoop
$idin=StringStripWS($idinraw,8)
$dirty=0
$clean = StringInStr($idin, "\")
if $clean<>0 Then
if StringLeft($idin, 4)="ACPI" then $dirty=1
if StringLeft($idin, 4)="IDE\" then $dirty=1
if StringLeft($idin, 5)="ROOT\" then $dirty=1
if StringLeft($idin, 8)="STORAGE\" then $dirty=1
if StringLeft($idin, 8)="DETECTED" then $dirty=1
$slashcount=0
$ampcount=0
$strlength=StringLen($idin)
for $trips=1 to $strlength
if StringMid($idin,$trips, 1)="\" then $slashcount=$slashcount+1
Next
for $trips=1 to $strlength
if StringMid($idin,$trips, 1)="&" then $ampcount=$ampcount+1
Next
if $slashcount=1 and $ampcount=0 then $dirty=1
if $dirty=0 then FileWriteLine("c:\dp\hwidlist.txt",$idin)
if $dirty=0 then $hwcount=$hwcount+1
EndIf
Until 1=2
FileClose("c:\dp\hwids.txt")
FileClose("c:\dp\hwidlist.txt")
;start section matching system's HWIDs to available drivers
$hwids=fileopen("c:\dp\hwidlist.txt",0)
FileOpen("c:\dp\tobeinst.txt",1)
$masterhwid=fileopen("c:\dp\masterhwid.txt",0)
Do
$hwidin = FileReadLine($hwids)
If @error = -1 Then ExitLoop
$hwgo=$hwgo+1
SplashTextOn("auto driver loader stage 2/7","running match scan " & $hwgo & " of " & $hwcount,-1,50)
do
$masthwidin = FileReadLine($masterhwid)
If @error = -1 Then ExitLoop
$lookformatch = StringInStr($masthwidin, $hwidin)
if $lookformatch<>0 Then
Do
$masthwidin = FileReadLine($masterhwid)
$findlocation = StringInStr($masthwidin, "********")
if $findlocation<>0 Then
FileWriteLine("c:\dp\tobeinst.txt",StringTrimLeft($masthwidin,8))
exitloop(2)
endif
until 1=2
EndIf
until 1=2
fileclose($masterhwid)
$masterhwid=FileOpen("c:\dp\masterhwid.txt",0)
until 1=2
fileclose($masterhwid)
fileclose("c:\dp\hwidinst.txt")
fileclose("c:\dp\tobeinst.txt")
SplashTextOn("auto driver loader stage 3/7", "finishing setup",-1,50)
; set up installer
fileopen("c:\dp\go.txt",1)
fileWriteLine("c:\dp\go.txt","x")
fileclose("c:\dp\go.txt")
$input=FileOpen("c:\dp\tobeinst.txt",0)
Do
$infname = FileReadLine($input)
If @error = -1 Then ExitLoop
$len=StringLen($infname)
for $count=$len to 1 step -1
$justdir=StringLeft($infname,$count)
IF StringRight($justdir,1)="\" Then
$justdir=StringLeft($infname,$count)
ExitLoop
EndIf
Next
$gotxt=fileopen ("c:\dp\go.txt",0)
Do
$txtin = FileReadLine($gotxt)
If @error = -1 Then ExitLoop
$finddup = StringInStr($txtin, $justdir)
if $finddup<>0 then ExitLoop
until 1=2
FileClose($gotxt)
if $finddup=0 then
FileOpen("c:\dp\go.txt",1)
FileWriteLine("c:\dp\go.txt", $justdir)
fileclose("c:\dp\go.txt")
EndIf
until 1=2
FileClose("c:\dp\tobeinst.txt")
FileClose("c:\dp\go.txt")
$gotext=fileopen("c:\dp\go.txt",0)
SplashTextOn("auto driver loader stage 4/7", "copying drivers to be installed",-1,50)
Do
$textinput = FileReadLine($gotext)
If @error = -1 Then ExitLoop
if $textinput<>"x" then DirCopy($textinput,"c:\dp\inst\" & $gobatcount,1)
$gobatcount=$gobatcount+1
until 1=2
SplashTextOn("auto driver loader stage 5/7", "installing your drivers now, the screen may flicker a few times",-1,50)
Run("c:\dp\inst\inst.cmd","",@SW_MINIMIZE)
sleep(3000) ;needed so the system can have time to execute the installer before skipping right by it
WinWaitClose("Driver Installer")
sleep(3000)
SplashTextOn("auto driver loader stage 6/7", "cleaning up",-1,50)
DirRemove("c:\d",1)
DirRemove("c:\dp",1)
run("c:\windows\system32\clean.exe")
splashoff()
Exit
Code for clean.au3:
SplashTextOn("auto driver loader stage 7/7","performing final stage of asetup",-1,50)
RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "DevicePath")
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "DevicePath", "REG_EXPAND_SZ", "%SystemRoot%\Inf")
RegDelete("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "Start Page")
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "Start Page", "REG_SZ", "http://www..com") ;removed my company name
RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main", "Default_Page_URL")
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main", "Default_Page_URL", "REG_SZ", "http://www..com") ;removed my company name
RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main", "Start Page")
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main", "Start Page", "REG_SZ", "http://www..com") ;removed my company name
RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel", "{20D04FE0-3AEA-1069-A2D8-08002B30309D}") ;my computer icon on desktop
Regwrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel", "{20D04FE0-3AEA-1069-A2D8-08002B30309D}", "REG_DWORD", "0") ;don't hide my computer icon on desktop
RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel", "{450D8FBA-AD25-11D0-98A8-0800361B1103}") ;my docs icon on desktop
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel", "{450D8FBA-AD25-11D0-98A8-0800361B1103}", "REG_DWORD", "0") ;don't hide my docs icon on desktop
FileOpen("c:\windows\system32\imgver.txt",1)
FileWriteLine("c:\windows\system32\imgver.txt","Windows XP OEM SP3 Image Version 1.6OSP 3/19/2009")
fileclose("c:\windows\system32\imgver.txt")
processclose("suppress.exe")
for $i=1 to 6
$allusers = FileFindFirstFile("c:\documents and settings\*.*")
Do
$user = FileFindNextFile($allusers)
If @error Then ExitLoop
FileDelete("c:\docume~1\"&$user&"\desktop\inter*.*")
FileDelete("c:\docume~1\"&$user&"\desktop\windo*.*")
FileDelete("c:\docume~1\"&$user&"\desktop\hwids.txt")
until 1=2
FileDelete("c:\*.txt")
DirRemove("c:\dp",1)
DirRemove("c:\d",1)
dirremove("c:\sysprep",1)
filedelete("c:\Documents and Settings\All Users\Start Menu\Programs\startup\just*.exe")
next
splashoff()
msgbox(0,"DONE!","The automated driver installation and system preparation process is now finished. After you close this message your should check to make sure all drivers are installed, and a reboot would be recommended to apply driver changes.")
Exit
I have the for-next loop because I found many times that C:\DP was not being fully removed, something I also experienced a lot with Finisher when using Base for SysPrep integration... The loop makes it more likely to succeed (hasn't failed yet this way...). I included the rest of the typical deletions to the loop just in case
Code for suppress.au3:
$start = TimerInit()
Do
sleep(2000)
if WinExists("Found New Hardware Wizard") then
WinActivate("Found New Hardware Wizard")
Send("{TAB}{TAB}{ENTER}")
endif
if WinExists("Hardware Update Wizard") then
WinActivate("Hardware Update Wizard")
Send("{ENTER}")
endif
if WinExists("System Settings Change") then
WinActivate("System Settings Change")
Send("{TAB}{ENTER}")
Exit
EndIf
Until TimerDiff($start)>90000
Exit
I have only noticed the System Settings Change window with XP Pro, so included the 90 second kill switch incase that window doesn't come up.
Any questions/comments, let 'er rip. I also apologize about the spacing being gone due to the code tag, if anybody is interested in downloading the code in the raw au3 format let me know, that way the code will be much easier to follow.....
Ian