$version = "1.8" $driverversion = "7.09" $filename="1800198F.exe" ; dont forget to change the FileInstall line as well becuase of AutoIt limitations it cant be a variable $totaldevices = 14 $historysearch = 'v 7.09 1/5/05' ;-------------------------------------------------------------- dim $models[($totaldevices +1)] $models[0] = ($totaldevices +1) $counter = 0 Do $models[$counter] = 0 $counter = $counter + 1 Until $counter = ($models[0] + 1) ; setup the defaults for each OS Select Case (@OSVersion = "WIN_XP" And @OSBuild = "3790") ; win2003 $MPSAposition = 7 $afterwizardwait = 10 ; seconds Case @OSVersion = "WIN_2000" $MPSAposition = 8 $afterwizardwait = 10 ; seconds Case @OSVersion = "WIN_XP" $MPSAposition = 7 $afterwizardwait = 10 ; seconds Case Else MsgBox(0, "OS Not Supported", "Very sorry, this OS is not currently supported.") Exit EndSelect ; parse command line args global $agree, $install = 0 ParseArgs() ; Give the user a warning and ask if its ok to continue. If $agree <> 1 Then $continue = MsgBox(4, "Comtrol Unofficial/Unsupported DeviceMaster Installation Script "& $version, "This script will install multiple DeviceMasters for Windows 2000/XP/2003 only."&@CRLF&"By continuing you can not hold Comtrol responsible for any damage/loss to hardware/software/data."&@CRLF&"Please backup your system!"&@CRLF&@CRLF&"Do you wish to continue?") If $continue = 7 OR $continue = -1 OR $continue = 2 OR $continue = 3 Then Exit EndIf EndIf ScriptSetup() Func ScriptSetup () ; Check to make sure dependencies are met for the application ; In this case I include the driver with the installer If @compiled Then If NOT FileInstall("1800198F.exe", @TempDir&"\"&$filename, 1) Then MsgBox(0, "File Installation Error", "This script could not copy '"&$filename&"' to the same directory the script is in.") Exit EndIf EndIf ; Check to make sure dependencies are met for the application ; I wish I did not require external apps for this to work correctly If @compiled Then If NOT FileInstall("SetACL.exe", @TempDir&"\SetACL.exe", 1) Then MsgBox(0, "File Installation Error", "This script could not copy 'SetACL.exe' to the same directory the script is in.") Exit EndIf EndIf If $install < 1 Then global $driverdir = InputBox("DeviceMaster Installer Script " & $version, "What directory should the DeviceMaster "&$driverversion&" driver exist in?" & @CRLF & @CRLF & "For example C:\Comtrol" & @CRLF, "C:\Comtrol", "", 400, 150) Else global $driverdir = "C:\Comtrol" EndIf If @Error = 1 Then Exit If NOT SearchFiles($driverdir, "HISTORY.TXT", $historysearch) Then ; Give the user a warning and ask if its ok to continue. If $install < 1 Then $continue = MsgBox(3, "Driver not detected", "I could not detect the correct Comtrol driver at "&$driverdir&@CRLF&@CRLF&" Yes) Installs driver automatically now"&@CRLF&" No) Continues the DeviceMaster install without driver"&@CRLF&" Cancel) Quits all installs and exits") Else $continue = 6 EndIf If $continue = -1 OR $continue = 2 OR $continue = 3 Then Exit ElseIf $continue = 6 Then Run(@TempDir & "\" & $filename) ;Run(@ScriptDir & '\' & $filename) ;WinZip Self-Extractor - $filename WinWait("WinZip Self-Extractor - "&$filename) If Not WinActive("WinZip Self-Extractor - "&$filename) Then WinActivate("WinZip Self-Extractor - "&$filename) WinWaitActive("WinZip Self-Extractor - "&$filename) Send("!f") Send($driverdir) Send("!u") WinWait("WinZip Self-Extractor", "unzipped successfully") If Not WinActive("WinZip Self-Extractor","unzipped successfully") Then WinActivate("WinZip Self-Extractor", "unzipped successfully") WinWaitActive("WinZip Self-Extractor","unzipped successfully") Send("{SPACE}") If Not WinActive("WinZip Self-Extractor - "&$filename) Then WinActivate("WinZip Self-Extractor - "&$filename) WinWaitActive("WinZip Self-Extractor - "&$filename) Send("!c") EndIf EndIf EndFunc ; if commandline installation options specified, then dont display any gui stuff. If $install < 1 Then $badchoicemsg = "" $bLoop = 1 While $bLoop = 1 $choice = 0 ;InputBox( "title", "Prompt" [, "Default" [, "password char" [, Width, Height [, Left, Top [, TimeOut]]]]] ) $choice = InputBox("Product Choice", "Choose a product from the "&$driverversion&" driver:" & @CRLF & _ " 0) Done selecting devices to install!" & @CRLF & _ " 1) DeviceMaster AIR" &@TAB&@TAB& $models[1] & @CRLF & _ " 2) DeviceMaster Pro 16" &@TAB&@TAB& $models[2] & @CRLF & _ " 3) DeviceMaster Pro 8" &@TAB&@TAB& $models[3] & @CRLF &_ " 4) DeviceMaster RTS 1" &@TAB&@TAB& $models[4] & @CRLF & _ " 5) DeviceMaster RTS 16" &@TAB& $models[5] & @CRLF & _ " 6) DeviceMaster RTS 32" &@TAB& $models[6] & @CRLF & _ " 7) DeviceMaster RTS 4" &@TAB&@TAB& $models[7] & @CRLF & _ " 8) DeviceMaster RTS 8" &@TAB&@TAB& $models[8] & @CRLF & _ " 9) DeviceMaster SerialHub 16" &@TAB& $models[9] & @CRLF & _ " 10) DeviceMaster SerialHub 8" &@TAB& $models[10] & @CRLF & _ " 11) RocketPort SerialHub IA 2" &@TAB& $models[11] & @CRLF & _ " 12) RocketPort SerialHub SI 2" &@TAB& $models[12] & @CRLF & _ " 13) RocketPort SerialHub SI 4" &@TAB& $models[13] & @CRLF & _ " 14) RocketPort SerialHub SI 8" &@TAB& $models[14] & @CRLF & _ @CRLF & @CRLF & "Please choose a number and press enter", $badchoicemsg, "", -1, 350) If @error = 1 Then Exit Else Select Case $choice = 0 $ports = 1 $bLoop = 0 Case $choice = 1 $product = "DeviceMaster AIR" $ports = 1 Case $choice = 2 $product = "DeviceMaster Pro 16" $ports = 16 Case $choice = 3 $product = "DeviceMaster Pro 8" $ports = 8 Case $choice = 4 $product = "DeviceMaster RTS 1" $ports = 1 Case $choice = 5 $product = "DeviceMaster RTS 16" $ports = 16 Case $choice = 6 $product = "DeviceMaster RTS 32" $ports = 32 Case $choice = 7 $product = "DeviceMaster RTS 4" $ports = 4 Case $choice = 8 $product = "DeviceMaster RTS 8" $ports = 8 Case $choice = 9 $product = "DeviceMaster SerialHub 16" $ports = 16 Case $choice = 10 $product = "DeviceMaster SerialHub 8" $ports = 8 Case $choice = 11 $product = "RocketPort SerialHub IA 2" $ports = 2 Case $choice = 12 $product = "RocketPort SerialHub SI 2" $ports = 2 Case $choice = 13 $product = "RocketPort SerialHub SI 4" $ports = 4 Case $choice = 14 $product = "RocketPort SerialHub SI 8" $ports = 8 Case Else $badchoicemsg = "Invalid choice selected!" EndSelect EndIf If ($badchoicemsg = "" And $choice <> 0) Then $badamountmsg = "" $amount = InputBox("How Many?", "Enter the number of " & $product & "'s you want installed", $badamountmsg, "", 300, 150) If @error = 1 Then Exit Else Select Case Number($amount) = 0 $bLoop = 0 Case Number($amount) > 0 $models[$choice] = $amount Case Else $badamountmsg = "Invalid selection! Please enter a number." EndSelect EndIf EndIf WEnd EndIf ;install gui test If $install < 1 Then $badchoicemsg = "" $bLoop = 1 While $bLoop = 1 $choice = 0 $choice = InputBox("Advanced Options", "These are advanced options most likely left alone." & @CRLF & _ " 0) Change nothing and continue" & @CRLF & _ " 1) Position of 'Multiport Serial Adapters'" &@TAB&@TAB&@TAB& $MPSAposition & @CRLF & _ " 2) Time in seconds to wait after Hardware Wizard" &@TAB& $afterwizardwait & @CRLF & _ @CRLF & @CRLF & "Please choose a number and press enter", $badchoicemsg, "", 340, 200) If @error = 1 Then Exit Else Select Case $choice = 0 $ports = 1 $bLoop = 0 Case $choice = 1 $MPSAposition = InputBox("Advanced Option Change", "Position of 'Multiport Serial Adapters' from the top during the Add New Hardware Wizard", $MPSAposition, "", 300, 150) If @error = 1 Then Exit EndIf Case $choice = 2 $afterwizardwait = InputBox("Advanced Option Change", "Time in seconds to wait to ensure the Add New Hardware Wizard is complete.", $afterwizardwait, "", 300, 150) If @error = 1 Then Exit EndIf Case Else $badchoicemsg = "Invalid choice selected!" EndSelect EndIf WEnd EndIf ;install gui test For $counter1 = 1 To $totaldevices Step 1 $counter2 = 0 While $counter2 < $models[$counter1] Select Case (@OSVersion = "WIN_XP" And @OSBuild = "3790") $result = InstallWin2003($counter1) Case @OSVersion = "WIN_2000" $result = InstallWin2000($counter1) Case @OSVersion = "WIN_XP" $result = InstallWinXP($counter1) Case Else MsgBox(0, "OS Not Supported", "Very sorry, this OS is not currently supported.") Exit EndSelect If $result = 0 Then $counter2 = $counter2 + 1 WEnd Next SplashOff() If $install < 1 Then MsgBox(0, "Complete", "DeviceMaster Installation(s) Complete" & @CRLF & "You can now setup the device(s) in the Device Manager") EndIf Exit Func ParseArgs () For $counter = 1 To $CmdLine[0] Step 1 If $CmdLine[$counter] = "-help" Or $CmdLine[$counter] = "--help" Or $CmdLine[$counter] = "/?" Then MsgBox(0, "Comtrol Unofficial/Unsupported DeviceMaster Installer", _ "Usage: " & @scriptname & " [-help] [-agree] [-install ] [-iniinstall [ ... n]]" & @CRLF & _ @CRLF & _ "This script will install multiple DeviceMasters for Windows 2000/XP/2003 only."&@CRLF&"By continuing you can not hold Comtrol responsible for any damage/loss to hardware/software/data."&@CRLF &_ @CRLF & _ "Options:" @CRLF & _ " -help This screen" & @CRLF & _ " -agree You already agree to the disclaimer, do not prompt me again." & @CRLF & _ " -mpsaposition The position from the top that 'Multiport Serial Adapter' appears" & @CRLF & _ " in your Add New Hardware Wizard."& @CRLF & _ " -afterwizardwait Time in seconds after the Hardware Wizard to ensure it is finished." & @CRLF & _ " -install Install DeviceMasters. Also assuming you want the driver extracted to C:\Comtrol!" & @CRLF & _ " Get model number from graphical mode listing."& @CRLF & _ " Count is number of DeviceMasters to install" & @CRLF & _ " -iniinstall [ ... n]" & @CRLF & _ " Install DeviceMasters from an ini file. " & @CRLF & _ " Also assuming you want the driver extracted to C:\Comtrol!" & @CRLF & _ " Get model number from graphical mode listing."& @CRLF & _ " Profile is the section name in the ini file" & @CRLF & _ " Example ini file test.ini:" & @CRLF & _ " [Profile Name]" & @CRLF & _ " Model = 5" & @CRLF & _ " Mac = 0 0 0 0 0 0" & @CRLF & _ " IP = 10.4.5.5" & @CRLF & _ " Mode = ip" & @CRLF & _ " Port0Mode = 232" & @CRLF & _ " Port1Mode = 422" & @CRLF & _ " Port2Mode = 485" & @CRLF & _ ) exit EndIf If $CmdLine[$counter] = "-agree" Then $agree = 1 EndIf If $CmdLine[$counter] = "-mpsaposition" Then $MPSAposition = $CmdLine[($counter + 1)] EndIf If $CmdLine[$counter] = "-afterwizardwait" Then $afterwizardwait = $CmdLine[($counter + 1)] EndIf If $CmdLine[$counter] = "-install" Then $install = 1 $models[$CmdLine[($counter+1)]] = $CmdLine[($counter+2)] EndIf If $CmdLine[$counter] = "-iniinstall" Then $install = 2 $offset = $counter+1 global $inifile = $CmdLine[($counter+1)] $totalprofiles = $CmdLine[0] - $offset global $iniprofiles[$totalprofiles] ScriptSetup() ;MsgBox(0, "DEBUG", "MADE IT HERE. cmds:"&$CmdLine[0]&"counter:"&$counter&"offset: "&$offset&"total profiles: "&$totalprofiles) For $counter2 = 0 To ($totalprofiles-1) Step 1 ;MsgBox(0, "DEBUG", "step:"&$counter2) $iniprofiles[$counter2] = $CmdLine[$counter2 + $offset + 1] $model = IniRead ($inifile, $iniprofiles[$counter2], "Model", "" ) ;MsgBox(0, "DEBUG", "Adding.. profile: "&$iniprofiles[$counter2]&" model: "&$model) ;If IsNumber($model) Then ;$models[$model] = $models[$model] + 1 ;MsgBox(0, "DEBUG", "Adding.. profile: "&$iniprofiles[$counter2]&" model: "&$model) ;EndIf $regbefore = GetRegistryEntries ("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\rpshsi\Parameters\") $regbefore2 = GetRegistryEntries ("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\Root\MULTIPORTSERIAL\") Select Case (@OSVersion = "WIN_XP" And @OSBuild = "3790") $result = InstallWin2003($model) Case @OSVersion = "WIN_2000" $result = InstallWin2000($model) Case @OSVersion = "WIN_XP" $result = InstallWinXP($model) Case Else MsgBox(0, "OS Not Supported", "Very sorry, this OS is not currently supported.") Exit EndSelect $regafter = GetRegistryEntries ("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\rpshsi\Parameters\") $regafter2 = GetRegistryEntries ("HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\Root\MULTIPORTSERIAL\") $addeddevice = ReturnUnique ($regafter, $regbefore) $addeddevice2 = ReturnUnique ($regafter2, $regbefore2) $addeddevice = StringStripWS ( $addeddevice, 8 ) $addeddevice2 = StringStripWS ( $addeddevice2, 8 ) ;$devnum = StringRight ( $addeddevice, 2 ) ;$regid = RegRead ( "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\Root\MULTIPORTSERIAL\"&$addeddevice2&"\ParentIdPrefix", "" ) $regid = RegRead ( "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\Root\MULTIPORTSERIAL\"&$addeddevice2, "ParentIdPrefix" ) ;MsgBox(0, "DEBUG", "DEBUG: just added device: "&$addeddevice&" & "&$addeddevice2&@CRLF&"regid: "&$regid) IniInstall($inifile, $iniprofiles[$counter2], $addeddevice, $regid) Next EndIf Next EndFunc Func IniInstall ($file, $name, $device, $regid) ;IniRead ( "filename", "section", "key", "default" ) If $device = "" Then MsgBox(0, "Error", "Could not detect which device was just installed. Cant continue with configuring it!" Exit EndIf $model = IniRead ($file, $name, "Model", "" ) Select Case $model = 1 $product = "DeviceMaster AIR" $ports = 1 Case $model = 2 $product = "DeviceMaster Pro 16" $ports = 16 Case $model = 3 $product = "DeviceMaster Pro 8" $ports = 8 Case $model = 4 $product = "DeviceMaster RTS 1" $ports = 1 Case $model = 5 $product = "DeviceMaster RTS 16" $ports = 16 Case $model = 6 $product = "DeviceMaster RTS 32" $ports = 32 Case $model = 7 $product = "DeviceMaster RTS 4" $ports = 4 Case $model = 8 $product = "DeviceMaster RTS 8" $ports = 8 Case $model = 9 $product = "DeviceMaster SerialHub 16" $ports = 16 Case $model = 10 $product = "DeviceMaster SerialHub 8" $ports = 8 Case $model = 11 $product = "RocketPort SerialHub IA 2" $ports = 2 Case $model = 12 $product = "RocketPort SerialHub SI 2" $ports = 2 Case $model = 13 $product = "RocketPort SerialHub SI 4" $ports = 4 Case $model = 14 $product = "RocketPort SerialHub SI 8" $ports = 8 Case Else MsgBox(0, "Error", "Error: There was no model specified for the requested profile") Exit EndSelect $mac = IniRead ($file, $name, "Mac", "0 0 0 0 0 0" ) $ip = IniRead ($file, $name, "IP", "" ) $mode = IniRead ($file, $name, "Mode", "mac" ) Select Case $mode = "ip" $mode = "0x00000000" Case $mode = "mac" $mode = "0x00000001" Case Else MsgBox(0, "Error", "Error: Invalid mode. Use either 'mac' or 'ip'") Exit EndSelect ; handle each port of the device Dim $portmodes[$ports] Dim $portcoms[$ports] For $port = 0 To ($ports - 1) Step 1 $portmodes[$port] = IniRead ($file, $name, "Port"&$port&"Mode", "232" ) $portcoms[$port] = IniRead ($file, $name, "Port"&$port&"COM", "" ) Next RegWrite ("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\rpshsi\Parameters\"&$device,"NumPorts", "REG_DWORD", "0x"&Hex($ports, 8)) RegWrite ("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\rpshsi\Parameters\"&$device, "MaxTimeOut", "REG_DWORD", "0x00000078") RegWrite ("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\rpshsi\Parameters\"&$device, "TcpMultiplier", "REG_DWORD", "0x00000001") RegWrite ("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\rpshsi\Parameters\"&$device, "Name", "REG_SZ", $product) RegWrite ("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\rpshsi\Parameters\"&$device, "MacAddr", "REG_SZ", $mac) RegWrite ("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\rpshsi\Parameters\"&$device, "IpAddr", "REG_SZ", $ip) RegWrite ("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\rpshsi\Parameters\"&$device, "UseMac", "REG_DWORD", $mode) For $port = 0 To ($ports - 1) Step 1 $regportname = "0000"&$port $regportname = StringRight ( $regportname, 4 ) $comnum = RegRead ("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\CtmPort\SiPORT\"&$regid&"&Port"&$regportname&"\Device Parameters","PortName") RegWrite ("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\rpshsi\Parameters\"&$device&"\Port"&$port, "Name", "REG_SZ", $comnum) RegWrite ("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\rpshsi\Parameters\"&$device&"\Port"&$port, "RsMode", "REG_DWORD", "0x"&Hex($portmodes[$port], 8)) $comports = DecodeArbiter() ; read COM arbiter before all com numbers change If $portcoms[$port] Then ; update all the places the COM# exists and the COM arbiter with the COM# the user requested regardless of any conflictions $portcoms[$port] = StringReplace($portcoms[$port], "com", "COM") $numold = StringTrimLeft($comnum, 3) ; trim the COM off COM#. ugly, but whatever. $numnew = StringTrimLeft($portcoms[$port], 3) ; trim the COM off COM#. ugly, but whatever. $devicemap = FindCOMMap("HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM\", $comnum) $nslinkprettyname = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\CtmPort\SiPORT\"&$regid&"&Port"&$regportname, "FriendlyName") $nslinkprettyname = StringReplace($nslinkprettyname, $comnum, $portcoms[$port]) RegWrite("HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM", $devicemap, "REG_SZ", $portcoms[$port]) ; typically the following registry location is not changable, so we change its permissions. i know its bad, but leave me alone RunWait(@ComSpec & " /c" & @TempDir & '\SetACL.exe -on "'&"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\CtmPort\SiPORT\"&$regid&"&Port"&$regportname&'" -ot reg -actn ace -rec yes -ace "n:Everyone;p:full"') RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\CtmPort\SiPORT\"&$regid&"&Port"&$regportname, "FriendlyName", "REG_SZ", $nslinkprettyname) RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\CtmPort\SiPORT\"&$regid&"&Port"&$regportname&"\Device Parameters", "PortName", "REG_SZ", $portcoms[$port]) RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\rpshsi\Parameters\"&$device&"\Port"&$port, "Name", "REG_SZ", $portcoms[$port]) $comports[$numold] = 0 $comports[$numnew] = 1 EndIf EncodeArbiter($comports) ; after all COM numbers change write back the new arbiter Next ;HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM\RpshSi4: "COM16" ;HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM\RpshSi4: "COM69" ;HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\CtmPort\SiPORT\1&173424ed&c&Port0000\FriendlyName: "Comtrol NS Link Port 0 (COM16)" ;HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\CtmPort\SiPORT\1&173424ed&c&Port0000\FriendlyName: "Comtrol NS Link Port 0 (COM69)" ;HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\CtmPort\SiPORT\1&173424ed&c&Port0000\Device Parameters\PortName: "COM16" ;HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\CtmPort\SiPORT\1&173424ed&c&Port0000\Device Parameters\PortName: "COM69" ;HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\rpshsi\Parameters\Device0\Port0\Name: "COM16" ;HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\rpshsi\Parameters\Device0\Port0\Name: "COM69" EndFunc Func EncodeArbiter ($comports) $newcomdbreg = "" For $p = 1 To $comports[0] Step 8 $byte = 0 If $comports[$p] Then $byte = $byte + 1 If $comports[($p+1)] Then $byte = $byte + 2 If $comports[($p+2)] Then $byte = $byte + 4 If $comports[($p+3)] Then $byte = $byte + 8 If $comports[($p+4)] Then $byte = $byte + 16 If $comports[($p+5)] Then $byte = $byte + 32 If $comports[($p+6)] Then $byte = $byte + 64 If $comports[($p+7)] Then $byte = $byte + 128 $newcomdbreg = $newcomdbreg & Hex ( $byte, 2 ) Next RegWrite( "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\COM Name Arbiter", "ComDB", "REG_BINARY", $newcomdbreg) EndFunc Func DecodeArbiter () $comdbreg = RegRead ( "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\COM Name Arbiter", "ComDB") $bytelength = StringLen ($comdbreg) / 2 $maxcomports = 5192 ; a multiple of 8 Dim $comdb[($bytelength +1)] $comdb[0] = $bytelength For $b = 1 To $comdb[0] Step 1 $comdb[$b] = StringLeft($comdbreg, 2) $comdbreg = StringTrimLeft($comdbreg, 2) Next ;dim $comports[($comdb[0] * 8 + 1)] dim $comports[($maxcomports + 1)] $comports[0] = $maxcomports ; initialize the ports to zero For $c = 1 To $comports[0] Step 1 $comports[$c] = 0 Next $range = 0 ; this number times the byte sequence number tells you the range of 8 ports that byte handles $rangecounter = 1 For $c = 1 To $comdb[0] Step 1 $deccomdb = Dec($comdb[$c]) For $power = 7 To 0 Step -1 $powertest = ($deccomdb - (2^$power)) If $powertest >= 0 Then $deccomdb = $deccomdb - (2^$power) $comports[(8 * $range + $power + 1)] = 1 EndIf Next $range = $range + 1 Next Return $comports EndFunc Func FindCOMMap ($path, $searchstring) $keynum = 1 $subkey = 1 $regentry = "" While $subkey $subkey = RegEnumVal($path, $keynum) $subval = RegRead($path, $subkey) If $subval = $searchstring Then $regentry = $subkey EndIf $keynum = $keynum + 1 WEnd Return $regentry EndFunc Func InstallWin2003 ($model) $checkforsignatures = 1 $portsignatures = 0 $done = 0 $count = 0 $didsomething = 0 $splashon = 0 $onceSelectDriver = 0 ; Launch Add New Hardware Wizard $HWPID = Run(@ComSpec & " /c" & @WindowsDir & "\system32\hdwwiz.cpl",) ;Run(@WindowsDir & "\system32\hdwwiz.cpl",) While $done = 0 If WinExists("Cannot Run Two Device Installations","You can install only one device at a time") Then SplashOff() If Not WinActive("Cannot Run Two Device Installations","You can install only one device at a time") Then WinActivate("Add Hardware Wizard","") If WinActive("Cannot Run Two Device Installations","You can install only one device at a time") Then Send("{SPACE}") Return 1 EndIf $didsomething = $didsomething + 1 $count = 0 EndIf If WinExists("Add Hardware Wizard","Welcome to the Add Hardware Wizard") Then SplashOff() If Not WinActive("Add Hardware Wizard","Welcome to the Add Hardware Wizard") Then WinActivate("Add Hardware Wizard","") If WinActive("Add Hardware Wizard","Welcome to the Add Hardware Wizard") Then Send("!n") EndIf $didsomething = $didsomething + 1 $count = 0 EndIf ; Is the hardware connected? If WinExists("Add Hardware Wizard","Have you already connected this hardware") Then SplashOff() If Not WinActive("Add Hardware Wizard","Have you already connected this hardware") Then WinActivate("Add Hardware Wizard","") If WinActive("Add Hardware Wizard","Have you already connected this hardware") Then Send("!y") Send("{ENTER}") EndIf $didsomething = $didsomething + 1 $count = 0 EndIf ; Choose a Hardware Task screen If WinExists("Add Hardware Wizard","From the list below, select") Then SplashOff() If Not WinActive("Add Hardware Wizard","From the list below, select") Then WinActivate("Add Hardware Wizard","") If WinActive("Add Hardware Wizard","From the list below, select") Then Send("{END}") Send("!n") EndIf $didsomething = $didsomething + 1 $count = 0 EndIf ; Search or manual? If WinExists("Add Hardware Wizard","The wizard can search for other hardware") Then SplashOff() If Not WinActive("Add Hardware Wizard","The wizard can search for other hardware") Then WinActivate("Add Hardware Wizard","") If WinActive("Add Hardware Wizard","The wizard can search for other hardware") Then Send("!m") Send("!n") EndIf $didsomething = $didsomething + 1 $count = 0 EndIf ; Hardware Type If WinExists("Add Hardware Wizard","If you do not see the hardware category") Then SplashOff() If Not WinActive("Add Hardware Wizard","If you do not see the hardware category") Then WinActivate("Add Hardware Wizard","") If WinActive("Add Hardware Wizard","If you do not see the hardware category") Then For $c = 1 to $MPSAposition Step 1 Send("{DOWN}") Next Send("!n") EndIf $didsomething = $didsomething + 1 $count = 0 EndIf ; Select a Device Driver With white in the middle If WinExists("Add Hardware Wizard","Select the manufacturer and model of your hardware device") Then SplashOff() If Not WinActive("Add Hardware Wizard","Select the manufacturer and model of your hardware device") Then WinActivate("Add Hardware Wizard","Select the manufacturer and model of your hardware device") If WinActive("Add Hardware Wizard","Select the manufacturer and model of your hardware device") Then ; This part makes me sad. The only way I can detect the difference between ; this 'select a driver' window and the previous one is the color at these coordinates ; If I find a better way I will change it. $size = WinGetPos("Add Hardware Wizard","Select the manufacturer and model of your hardware device") $var = PixelGetColor( ($size[0] + 186) , ($size[1] + 246) ) ;$continue = MsgBox(3, "DEBUG", "Color at x:"&($size[0] + 186)&", y:"&($size[1] + 246)&" is "&$var) ;If $continue = -1 OR $continue = 2 OR $continue = 3 Then Exit If $var = 16777215 Then Send("{TAB}") Send("{TAB}") For $choiceselection = 1 To ($model-1) Step 1 Send ("{DOWN}") Next Send("!n") EndIf EndIf $didsomething = $didsomething + 1 $count = 0 EndIf ; Select a Device Driver With no white in the middle If WinExists("Add Hardware Wizard","Select the manufacturer and model of your hardware device") Then SplashOff() If Not WinActive("Add Hardware Wizard","Select the manufacturer and model of your hardware device") Then WinActivate("Add Hardware Wizard","Select the manufacturer and model of your hardware device") If WinActive("Add Hardware Wizard","Select the manufacturer and model of your hardware device") Then ; This part makes me sad. The only way I can detect the difference between ; this 'select a driver' window and the previous one is the color at these coordinates ; If I find a better way I will change it. $size = WinGetPos("Add Hardware Wizard","Select the manufacturer and model of your hardware device") $var = PixelGetColor( ($size[0] + 186) , ($size[1] + 246) ) ;$continue = MsgBox(3, "DEBUG", "Color at x:"&($size[0] + 186)&", y:"&($size[1] + 246)&" is "&$var) ;If $continue = -1 OR $continue = 2 OR $continue = 3 Then Exit If $var <> 16777215 Then Send("!h") EndIf EndIf $didsomething = $didsomething + 1 $count = 0 EndIf ; Select a Device Driver With white in the middle If WinExists("Found New Hardware Wizard","Select the manufacturer and model of your hardware device") Then SplashOff() If Not WinActive("Found New Hardware Wizard","Select the manufacturer and model of your hardware device") Then WinActivate("Found New Hardware Wizard","Select the manufacturer and model of your hardware device") If WinActive("Found New Hardware Wizard","Select the manufacturer and model of your hardware device") Then ; This part makes me sad. The only way I can detect the difference between ; this 'select a driver' window and the previous one is the color at these coordinates ; If I find a better way I will change it. $size = WinGetPos("Found New Hardware Wizard","Select the manufacturer and model of your hardware device") $var = PixelGetColor( ($size[0] + 186) , ($size[1] + 246) ) ;$continue = MsgBox(3, "DEBUG", "Color at x:"&($size[0] + 186)&", y:"&($size[1] + 246)&" is "&$var) ;If $continue = -1 OR $continue = 2 OR $continue = 3 Then Exit If $var = 16777215 Then Send("!n") EndIf EndIf $didsomething = $didsomething + 1 $count = 0 EndIf ; Searching for hardware If WinExists("Add Hardware Wizard","This wizard is searching for hardware") Then SplashOff() ;If Not WinActive("Add Hardware Wizard","The wizard is searching for hardware") Then WinActivate("Add/Remove Hardware Wizard","The wizard is searching for hardware") $didsomething = $didsomething + 1 $count = 0 EndIf ; Have Disk to Comtrol folder If WinExists("Install From Disk","") Then SplashOff() If Not WinActive("Install From Disk","") Then WinActivate("Install From Disk","") If WinActive("Install From Disk","") Then Send("!c") Send($driverdir) Send("{ENTER}") EndIf $didsomething = $didsomething + 1 $count = 0 EndIf ; Start Hardware Installation If WinExists("Add Hardware Wizard","Hardware to install") Then SplashOff() If Not WinActive("Add Hardware Wizard","Hardware to install") Then WinActivate("Add Hardware Wizard","Hardware to install") If WinActive("Add Hardware Wizard","Hardware to install") Then Send("!n") EndIf $didsomething = $didsomething + 1 $count = 0 EndIf ; Hardware Installation If WinExists("Hardware Installation","")Then SplashOff() If Not WinActive("Hardware Installation","") Then WinActivate("Hardware Installation","") If WinActive("Hardware Installation","") Then Send("!c") EndIf $didsomething = $didsomething + 1 $count = 0 EndIf ; Software Installation If WinExists("Software Installation","") Then SplashOff() If Not WinActive("Software Installation","") Then WinActivate("Software Installation","") If WinActive("Software Installation","") Then Send("!c") EndIf $didsomething = $didsomething + 1 $count = 0 EndIf ; Completed If WinExists("Add Hardware Wizard","The following hardware was installed") Then SplashOff() If Not WinActive("Add Hardware Wizard","The following hardware was installed") Then WinActivate("Add Hardware Wizard","The following hardware was installed") If WinActive("Add Hardware Wizard","The following hardware was installed") Then Send("{ENTER}") EndIf $didsomething = $didsomething + 1 $count = 0 EndIf ; Found New Hardware Wizard If WinExists("Found New Hardware Wizard","Can Windows connect to Windows Update") Then SplashOff() If Not WinActive("Found New Hardware Wizard","Can Windows connect to Windows Update") Then WinActivate("Found New Hardware Wizard","Can Windows connect to Windows Update") If WinActive("Found New Hardware Wizard","Can Windows connect to Windows Update") Then Send("!t") Send("!n") EndIf $didsomething = $didsomething + 1 $count = 0 EndIf If WinExists("Found New Hardware Wizard", "This wizard helps you install software for") Then SplashOff() If Not WinActive("Found New Hardware Wizard","This wizard helps you install software for") Then WinActivate("Found New Hardware Wizard","This wizard helps you install software for") If WinActive("Found New Hardware Wizard","This wizard helps you install software for") Then Send("!s") Send("!n") ;WinWait("Found New Hardware Wizard","This wizard will complete the installation for this device") ;If Not WinActive("Found New Hardware Wizard","") Then WinActivate("Found New Hardware Wizard","") ;WinWaitActive("Found New Hardware Wizard","") ;ControlCommand("Found New Hardware Wizard", "", "&Specify a location", "Check", "") ;ControlCommand("Found New Hardware Wizard", "", "Floppy &disk drives", "UnCheck", "") ;ControlCommand("Found New Hardware Wizard", "", "&CD-ROM drives", "UnCheck", "") ;ControlCommand("Found New Hardware Wizard", "", "&Specify a location", "UnCheck", "") ;Send("!n") EndIf $didsomething = $didsomething + 1 $count = 0 EndIf ; Chose search and installation options If WinExists("Found New Hardware Wizard","Don't search. I will choose the driver") Then SplashOff() If Not WinActive("Found New Hardware Wizard","Don't search. I will choose the driver") Then WinActivate("Found New Hardware Wizard","Don't search. I will choose the driver") If WinActive("Found New Hardware Wizard","Don't search. I will choose the driver") Then Send("!d") Send("!n") EndIf $didsomething = $didsomething + 1 $count = 0 EndIf ; Completed If WinExists("Found New Hardware Wizard","The wizard has finished") Then SplashOff() If Not WinActive("Found New Hardware Wizard","The wizard has finished") Then WinActivate("Found New Hardware Wizard","The wizard has finished") If WinActive("Found New Hardware Wizard","The wizard has finished") Then Send("{ENTER}") EndIf $didsomething = $didsomething + 1 $count = 0 EndIf ; Hardware wizard still open If WinExists("Add Hardware Wizard","") Then SplashOff() $didsomething = $didsomething + 1 $count = 0 EndIf ; Hardware wizard still open If WinExists("Found New Hardware Wizard","") Then SplashOff() $didsomething = $didsomething + 1 $count = 0 EndIf ; Hardware wizard still open AutoItSetOption("WinTitleMatchMode", 4) If WinExists("Comtrol NS Link Port","") Then SplashOff() $didsomething = $didsomething + 1 $count = 0 EndIf AutoItSetOption("WinTitleMatchMode", 1) ; Hardware wizard still open ;classname=Shell_TrayWnd ;AutoItSetOption("WinTitleMatchMode", 4) ;If WinExists("classname=tooltips_class32") Then ; SplashOff() ; $didsomething = $didsomething + 1 ; $count = 0 ; EndIf ; AutoItSetOption("WinTitleMatchMode", 1) ; If the hardware wizard process is still running then dont exit If ProcessExists($HWPID) Then SplashOff() $didsomething = $didsomething + 1 $count = 0 EndIf If $didsomething = 0 Then If $count >= ($afterwizardwait * 4) Then $done = 1 Else $count = $count + 1 $countdown = int((($afterwizardwait * 4) - $count) /4) Sleep(250) EndIf If $splashon Then ControlSetText("Waiting for Hardware Wizard", "", "Static1", "Waiting to be sure hardware wizard is complete... $countdown seconds remain...") Else SplashTextOn("Waiting for Hardware Wizard", "Waiting to be sure hardware wizard is complete... "&$countdown&" seconds remain...", 550, 50) EndIf Else ;$continue = MsgBox(3, "DEBUG", "Pausing cause we saw a window and did something...") ;If $continue = -1 OR $continue = 2 OR $continue = 3 Then Exit EndIf $didsomething = 0 WEnd EndFunc Func InstallWinXP ($model) $checkforsignatures = 1 $portsignatures = 0 $done = 0 $count = 0 $didsomething = 0 $splashon = 0 $onceSelectDriver = 0 ; Launch Add New Hardware Wizard $HWPID = Run(@ComSpec & " /c" & @WindowsDir & "\system32\hdwwiz.cpl",) ;Run(@WindowsDir & "\system32\hdwwiz.cpl",) While $done = 0 If WinExists("Cannot Run Two Device Installations","You can install only one device at a time") Then SplashOff() If Not WinActive("Cannot Run Two Device Installations","You can install only one device at a time") Then WinActivate("Add Hardware Wizard","") If WinActive("Cannot Run Two Device Installations","You can install only one device at a time") Then Send("{SPACE}") Return 1 EndIf $didsomething = $didsomething + 1 $count = 0 EndIf If WinExists("Add Hardware Wizard","Welcome to the Add Hardware Wizard") Then SplashOff() If Not WinActive("Add Hardware Wizard","Welcome to the Add Hardware Wizard") Then WinActivate("Add Hardware Wizard","") If WinActive("Add Hardware Wizard","Welcome to the Add Hardware Wizard") Then Send("!n") EndIf $didsomething = $didsomething + 1 $count = 0 EndIf ; Is the hardware connected? If WinExists("Add Hardware Wizard","Have you already connected this hardware") Then SplashOff() If Not WinActive("Add Hardware Wizard","Have you already connected this hardware") Then WinActivate("Add Hardware Wizard","") If WinActive("Add Hardware Wizard","Have you already connected this hardware") Then Send("!y") Send("!n") EndIf $didsomething = $didsomething + 1 $count = 0 EndIf ; Choose a Hardware Task screen If WinExists("Add Hardware Wizard","From the list below, select") Then SplashOff() If Not WinActive("Add Hardware Wizard","From the list below, select") Then WinActivate("Add Hardware Wizard","") If WinActive("Add Hardware Wizard","From the list below, select") Then Send("{END}") Send("!n") EndIf $didsomething = $didsomething + 1 $count = 0 EndIf ; Search or manual? If WinExists("Add Hardware Wizard","The wizard can search for other hardware") Then SplashOff() If Not WinActive("Add Hardware Wizard","The wizard can search for other hardware") Then WinActivate("Add Hardware Wizard","") If WinActive("Add Hardware Wizard","The wizard can search for other hardware") Then Send("!m") Send("!n") EndIf $didsomething = $didsomething + 1 $count = 0 EndIf ; Hardware Type If WinExists("Add Hardware Wizard","If you do not see the hardware category") Then SplashOff() If Not WinActive("Add Hardware Wizard","If you do not see the hardware category") Then WinActivate("Add Hardware Wizard","") If WinActive("Add Hardware Wizard","If you do not see the hardware category") Then For $c = 1 to $MPSAposition Step 1 Send("{DOWN}") Next Send("!n") EndIf $didsomething = $didsomething + 1 $count = 0 EndIf ; Select a Device Driver With white in the middle If WinExists("Add Hardware Wizard","Select the manufacturer and model of your hardware device") Then SplashOff() If Not WinActive("Add Hardware Wizard","Select the manufacturer and model of your hardware device") Then WinActivate("Add Hardware Wizard","Select the manufacturer and model of your hardware device") If WinActive("Add Hardware Wizard","Select the manufacturer and model of your hardware device") Then ; This part makes me sad. The only way I can detect the difference between ; this 'select a driver' window and the previous one is the color at these coordinates ; If I find a better way I will change it. $size = WinGetPos("Add Hardware Wizard","Select the manufacturer and model of your hardware device") $var = PixelGetColor( ($size[0] + 186) , ($size[1] + 246) ) ;$continue = MsgBox(3, "DEBUG", "Color at x:"&($size[0] + 186)&", y:"&($size[1] + 246)&" is "&$var) ;If $continue = -1 OR $continue = 2 OR $continue = 3 Then Exit If $var = 16777215 Then ;Send("!n") Send("{TAB}") Send("{TAB}") For $choiceselection = 1 To ($model-1) Step 1 Send ("{DOWN}") Next Send("!n") EndIf EndIf $didsomething = $didsomething + 1 $count = 0 EndIf ; Select a Device Driver With no white in the middle If WinExists("Add Hardware Wizard","Select the manufacturer and model of your hardware device") Then SplashOff() If Not WinActive("Add Hardware Wizard","Select the manufacturer and model of your hardware device") Then WinActivate("Add Hardware Wizard","Select the manufacturer and model of your hardware device") If WinActive("Add Hardware Wizard","Select the manufacturer and model of your hardware device") Then ; This part makes me sad. The only way I can detect the difference between ; this 'select a driver' window and the previous one is the color at these coordinates ; If I find a better way I will change it. $size = WinGetPos("Add Hardware Wizard","Select the manufacturer and model of your hardware device") $var = PixelGetColor( ($size[0] + 186) , ($size[1] + 246) ) ;$continue = MsgBox(3, "DEBUG", "Color at x:"&($size[0] + 186)&", y:"&($size[1] + 246)&" is "&$var) ;If $continue = -1 OR $continue = 2 OR $continue = 3 Then Exit If $var <> 16777215 Then Send("!h") EndIf EndIf $didsomething = $didsomething + 1 $count = 0 EndIf ; Select a Device Driver With white in the middle If WinExists("Found New Hardware Wizard","Select the manufacturer and model of your hardware device") Then SplashOff() If Not WinActive("Found New Hardware Wizard","Select the manufacturer and model of your hardware device") Then WinActivate("Found New Hardware Wizard","Select the manufacturer and model of your hardware device") If WinActive("Found New Hardware Wizard","Select the manufacturer and model of your hardware device") Then ; This part makes me sad. The only way I can detect the difference between ; this 'select a driver' window and the previous one is the color at these coordinates ; If I find a better way I will change it. $size = WinGetPos("Found New Hardware Wizard","Select the manufacturer and model of your hardware device") $var = PixelGetColor( ($size[0] + 186) , ($size[1] + 246) ) ;$continue = MsgBox(3, "DEBUG", "Color at x:"&($size[0] + 186)&", y:"&($size[1] + 246)&" is "&$var) ;If $continue = -1 OR $continue = 2 OR $continue = 3 Then Exit If $var = 16777215 Then Send("!n") EndIf EndIf $didsomething = $didsomething + 1 $count = 0 EndIf ; Searching for hardware If WinExists("Add Hardware Wizard","This wizard is searching for hardware") Then SplashOff() ;If Not WinActive("Add Hardware Wizard","The wizard is searching for hardware") Then WinActivate("Add/Remove Hardware Wizard","The wizard is searching for hardware") $didsomething = $didsomething + 1 $count = 0 EndIf ; Have Disk to Comtrol folder If WinExists("Install From Disk","") Then SplashOff() If Not WinActive("Install From Disk","") Then WinActivate("Install From Disk","") If WinActive("Install From Disk","") Then Send("!c") Send($driverdir) Send("{ENTER}") EndIf $didsomething = $didsomething + 1 $count = 0 EndIf ; Start Hardware Installation If WinExists("Add Hardware Wizard","Hardware to install") Then SplashOff() If Not WinActive("Add Hardware Wizard","Hardware to install") Then WinActivate("Add Hardware Wizard","") If WinActive("Add Hardware Wizard","Hardware to install") Then Send("!n") EndIf $didsomething = $didsomething + 1 $count = 0 EndIf ; Hardware Installation If WinExists("Hardware Installation","")Then SplashOff() If Not WinActive("Hardware Installation","") Then WinActivate("Hardware Installation","") If WinActive("Hardware Installation","") Then Send("!c") EndIf $didsomething = $didsomething + 1 $count = 0 EndIf ; Software Installation If WinExists("Software Installation","") Then SplashOff() If Not WinActive("Software Installation","") Then WinActivate("Software Installation","") If WinActive("Software Installation","") Then Send("!c") EndIf $didsomething = $didsomething + 1 $count = 0 EndIf ; Completed If WinExists("Add Hardware Wizard","The following hardware was installed") Then SplashOff() If Not WinActive("Add Hardware Wizard","The following hardware was installed") Then WinActivate("Add Hardware Wizard","") If WinActive("Add Hardware Wizard","The following hardware was installed") Then Send("{ENTER}") EndIf $didsomething = $didsomething + 1 $count = 0 EndIf ; Found New Hardware Wizard If WinExists("Found New Hardware Wizard","Can Windows connect to Windows Update") Then SplashOff() If Not WinActive("Found New Hardware Wizard","Can Windows connect to Windows Update") Then WinActivate("Found New Hardware Wizard","") If WinActive("Found New Hardware Wizard","Can Windows connect to Windows Update") Then Send("!t") Send("!n") EndIf $didsomething = $didsomething + 1 $count = 0 EndIf If WinExists("Found New Hardware Wizard", "This wizard helps you install software for") Then SplashOff() If Not WinActive("Found New Hardware Wizard","This wizard helps you install software for") Then WinActivate("Found New Hardware Wizard","This wizard helps you install software for") If WinActive("Found New Hardware Wizard","This wizard helps you install software for") Then Send("!s") Send("!n") ;WinWait("Found New Hardware Wizard","This wizard will complete the installation for this device") ;If Not WinActive("Found New Hardware Wizard","") Then WinActivate("Found New Hardware Wizard","") ;WinWaitActive("Found New Hardware Wizard","") ;ControlCommand("Found New Hardware Wizard", "", "&Specify a location", "Check", "") ;ControlCommand("Found New Hardware Wizard", "", "Floppy &disk drives", "UnCheck", "") ;ControlCommand("Found New Hardware Wizard", "", "&CD-ROM drives", "UnCheck", "") ;ControlCommand("Found New Hardware Wizard", "", "&Specify a location", "UnCheck", "") ;Send("!n") EndIf $didsomething = $didsomething + 1 $count = 0 EndIf ; Chose search and installation options If WinExists("Found New Hardware Wizard","Don't search. I will choose the driver") Then SplashOff() If Not WinActive("Found New Hardware Wizard","Don't search. I will choose the driver") Then WinActivate("Found New Hardware Wizard","") If WinActive("Found New Hardware Wizard","Don't search. I will choose the driver") Then Send("!d") Send("!n") EndIf $didsomething = $didsomething + 1 $count = 0 EndIf ; Completed If WinExists("Found New Hardware Wizard","The wizard has finished") Then SplashOff() If Not WinActive("Found New Hardware Wizard","The wizard has finished") Then WinActivate("Found New Hardware Wizard","") If WinActive("Found New Hardware Wizard","The wizard has finished") Then Send("{ENTER}") EndIf $didsomething = $didsomething + 1 $count = 0 EndIf ; Hardware wizard still open If WinExists("Add Hardware Wizard","") Then SplashOff() $didsomething = $didsomething + 1 $count = 0 EndIf ; Hardware wizard still open If WinExists("Found New Hardware Wizard","") Then SplashOff() $didsomething = $didsomething + 1 $count = 0 EndIf ; Hardware wizard still open If WinExists("Comtrol NS Link Port","") Then SplashOff() $didsomething = $didsomething + 1 $count = 0 EndIf ; If the hardware wizard process is still running then dont exit If ProcessExists($HWPID) Then SplashOff() $didsomething = $didsomething + 1 $count = 0 EndIf If $didsomething = 0 Then If $count >= ($afterwizardwait * 4) Then $done = 1 Else $count = $count + 1 $countdown = int((($afterwizardwait * 4) - $count) /4) Sleep(250) EndIf If $splashon Then ControlSetText("Waiting for Hardware Wizard", "", "Static1", "Waiting to be sure hardware wizard is complete... $countdown seconds remain...") Else SplashTextOn("Waiting for Hardware Wizard", "Waiting to be sure hardware wizard is complete... "&$countdown&" seconds remain...", 550, 50) EndIf Else ;$continue = MsgBox(3, "DEBUG", "Pausing cause we saw a window and did something...") ;If $continue = -1 OR $continue = 2 OR $continue = 3 Then Exit EndIf $didsomething = 0 WEnd EndFunc Func InstallWin2000 ($model) $checkforsignatures = 1 $portsignatures = 0 $done = 0 $count = 0 $didsomething = 0 $splashon = 0 ; Launch Add New Hardware Wizard ;$HWPID = Run(@ComSpec & " /c" & @WindowsDir & "\system32\hdwwiz.cpl",) Local $RUNDLL32 = @SystemDir & "\rundll32.exe" ;$HWPID = Run($RUNDLL32 SHELL32.DLL,Control_RunDLL hdwwiz.cpl) $HWPID = Run($RUNDLL32 & " shell32.dll,Control_RunDLL hdwwiz.cpl") ;Run(@WindowsDir & "\system32\hdwwiz.cpl",) While $done = 0 If WinExists("Cannot Run Two Device Installations","You can install only one device at a time") Then SplashOff() If Not WinActive("Cannot Run Two Device Installations","You can install only one device at a time") Then WinActivate("Add Hardware Wizard","") If WinActive("Cannot Run Two Device Installations","You can install only one device at a time") Then Send("{SPACE}") Return 1 EndIf $didsomething = $didsomething + 1 $count = 0 EndIf If WinExists("Add/Remove Hardware Wizard","Welcome to the Add/Remove Hardware Wizard") Then SplashOff() If Not WinActive("Add/Remove Hardware Wizard","Welcome to the Add/Remove Hardware Wizard") Then WinActivate("Add/Remove Hardware Wizard","Welcome to the Add/Remove Hardware Wizard") If WinActive("Add/Remove Hardware Wizard","Welcome to the Add/Remove Hardware Wizard") Then Send("!n") EndIf $didsomething = $didsomething + 1 $count = 0 EndIf ; Searching for hardware If WinExists("Add/Remove Hardware Wizard","Windows is searching for new Plug and Play hardware") Then SplashOff() If Not WinActive("Add/Remove Hardware Wizard","Windows is searching for new Plug and Play hardware") Then WinActivate("Add/Remove Hardware Wizard","Windows is searching for new Plug and Play hardware") $didsomething = $didsomething + 1 $count = 0 EndIf ; Choose a Hardware Task screen If WinExists("Add/Remove Hardware Wizard","Select the hardware task you want to perform") Then SplashOff() If Not WinActive("Add/Remove Hardware Wizard","Select the hardware task you want to perform") Then WinActivate("Add/Remove Hardware Wizard","Select the hardware task you want to perform") If WinActive("Add/Remove Hardware Wizard","Select the hardware task you want to perform") Then Send("!a") Send("!n") EndIf $didsomething = $didsomething + 1 $count = 0 EndIf ; Choose a Hardware Device If WinExists("Add/Remove Hardware Wizard","The following hardware is already installed on your computer.") Then SplashOff() If Not WinActive("Add/Remove Hardware Wizard","The following hardware is already installed on your computer.") Then WinActivate("Add/Remove Hardware Wizard","The following hardware is already installed on your computer.") If WinActive("Add/Remove Hardware Wizard","The following hardware is already installed on your computer.") Then Send("{SPACE}") Send("!n") EndIf $didsomething = $didsomething + 1 $count = 0 EndIf ; Find New Hardware If WinExists("Add/Remove Hardware Wizard","When Windows detects new hardware") Then SplashOff() If Not WinActive("Add/Remove Hardware Wizard","When Windows detects new hardware") Then WinActivate("Add/Remove Hardware Wizard","When Windows detects new hardware") If WinActive("Add/Remove Hardware Wizard","When Windows detects new hardware") Then Send("!o") Send("!n") EndIf $didsomething = $didsomething + 1 $count = 0 EndIf ; Hardware Type If WinExists("Add/Remove Hardware Wizard","Select the type of hardware you want to install") Then SplashOff() If Not WinActive("Add/Remove Hardware Wizard","Select the type of hardware you want to install") Then WinActivate("Add/Remove Hardware Wizard","Select the type of hardware you want to install") If WinActive("Add/Remove Hardware Wizard","Select the type of hardware you want to install") Then For $c = 1 to $MPSAposition Step 1 Send("{DOWN}") Next Send("!n") EndIf $didsomething = $didsomething + 1 $count = 0 EndIf ; Select a Device Driver With white in the middle If WinExists("Add/Remove Hardware Wizard","Select the manufacturer and model of your hardware device") Then SplashOff() If Not WinActive("Add/Remove Hardware Wizard","Select the manufacturer and model of your hardware device") Then WinActivate("Add Hardware Wizard","") If WinActive("Add/Remove Hardware Wizard","Select the manufacturer and model of your hardware device") Then ; This part makes me sad. The only way I can detect the difference between ; this 'select a driver' window and the previous one is the color at these coordinates ; If I find a better way I will change it. $size = WinGetPos("Add/Remove Hardware Wizard","Select the manufacturer and model of your hardware device") $var = PixelGetColor( ($size[0] + 186) , ($size[1] + 246) ) ;$continue = MsgBox(3, "DEBUG", "Color at x:"&($size[0] + 186)&", y:"&($size[1] + 246)&" is "&$var) ;If $continue = -1 OR $continue = 2 OR $continue = 3 Then Exit If $var = 16777215 Then Send("!d") For $choiceselection = 1 To ($model-1) Step 1 Send ("{DOWN}") Next Send("!n") EndIf EndIf $didsomething = $didsomething + 1 $count = 0 EndIf ; Select a Device Driver With no white in the middle If WinExists("Add/Remove Hardware Wizard","Select the manufacturer and model of your hardware device") Then SplashOff() If Not WinActive("Add/Remove Hardware Wizard","Select the manufacturer and model of your hardware device") Then WinActivate("Add Hardware Wizard","") If WinActive("Add/Remove Hardware Wizard","Select the manufacturer and model of your hardware device") Then ; This part makes me sad. The only way I can detect the difference between ; this 'select a driver' window and the previous one is the color at these coordinates ; If I find a better way I will change it. $size = WinGetPos("Add/Remove Hardware Wizard","Select the manufacturer and model of your hardware device") $var = PixelGetColor( ($size[0] + 186) , ($size[1] + 246) ) ;$continue = MsgBox(3, "DEBUG", "Color at x:"&($size[0] + 186)&", y:"&($size[1] + 246)&" is "&$var) ;If $continue = -1 OR $continue = 2 OR $continue = 3 Then Exit If $var <> 16777215 Then Send("!h") EndIf EndIf $didsomething = $didsomething + 1 $count = 0 EndIf ; Have Disk to Comtrol folder If WinExists("Install From Disk","") Then SplashOff() If Not WinActive("Install From Disk","") Then WinActivate("Install From Disk","") If WinActive("Install From Disk","") Then Send("!c") Send($driverdir) Send("{ENTER}") EndIf $didsomething = $didsomething + 1 $count = 0 EndIf ; Start Hardware Installation If WinExists("Add/Remove Hardware Wizard","Windows will use default settings to install the software") Then SplashOff() If Not WinActive("Add/Remove Hardware Wizard","Windows will use default settings to install the software") Then WinActivate("Add/Remove Hardware Wizard","Windows will use default settings to install the software") If WinActive("Add/Remove Hardware Wizard","Windows will use default settings to install the software") Then Send("!n") EndIf $didsomething = $didsomething + 1 $count = 0 EndIf ; Digital Signature Not Found If WinExists("Digital Signature Not Found","") Then SplashOff() If Not WinActive("Digital Signature Not Found","") Then WinActivate("Digital Signature Not Found","Digital Signature Not Found") If WinActive("Digital Signature Not Found","") Then Send("!y") EndIf $didsomething = $didsomething + 1 $count = 0 EndIf ; Completed If WinExists("Add/Remove Hardware Wizard","Completing the Add/Remove Hardware Wizard") Then SplashOff() If Not WinActive("Add/Remove Hardware Wizard","Completing the Add/Remove Hardware Wizard") Then WinActivate("Add/Remove Hardware Wizard","Completing the Add/Remove Hardware Wizard") If WinActive("Add/Remove Hardware Wizard","Completing the Add/Remove Hardware Wizard") Then Send("{ENTER}") EndIf $didsomething = $didsomething + 1 $count = 0 EndIf ; Found New Hardware Wizard If WinExists("Found New Hardware Wizard","") Then SplashOff() Exit If Not WinActive("Found New Hardware Wizard","") Then WinActivate("Found New Hardware Wizard","") If WinActive("Found New Hardware Wizard","") Then Send("!n") EndIf $didsomething = $didsomething + 1 $count = 0 EndIf ; Select a Device Driver With white in the middle If WinExists("Found New Hardware Wizard","Select the manufacturer and model of your hardware device") Then SplashOff() If Not WinActive("Found New Hardware Wizard","Select the manufacturer and model of your hardware device") Then WinActivate("Add Hardware Wizard","") If WinActive("Found New Hardware Wizard","Select the manufacturer and model of your hardware device") Then ; This part makes me sad. The only way I can detect the difference between ; this 'select a driver' window and the previous one is the color at these coordinates ; If I find a better way I will change it. $size = WinGetPos("Found New Hardware Wizard","Select the manufacturer and model of your hardware device") $var = PixelGetColor( ($size[0] + 186) , ($size[1] + 246) ) ;$continue = MsgBox(3, "DEBUG", "Color at x:"&($size[0] + 186)&", y:"&($size[1] + 246)&" is "&$var) ;If $continue = -1 OR $continue = 2 OR $continue = 3 Then Exit If $var = 16777215 Then Send("!n") EndIf EndIf $didsomething = $didsomething + 1 $count = 0 EndIf ; Select a Device Driver With no white in the middle If WinExists("Found New Hardware Wizard","Select the manufacturer and model of your hardware device") Then SplashOff() If Not WinActive("Found New Hardware Wizard","Select the manufacturer and model of your hardware device") Then WinActivate("Add Hardware Wizard","") If WinActive("Found New Hardware Wizard","Select the manufacturer and model of your hardware device") Then ; This part makes me sad. The only way I can detect the difference between ; this 'select a driver' window and the previous one is the color at these coordinates ; If I find a better way I will change it. $size = WinGetPos("Add Hardware Wizard","Select the manufacturer and model of your hardware device") $var = PixelGetColor( ($size[0] + 186) , ($size[1] + 246) ) ;$continue = MsgBox(3, "DEBUG", "Color at x:"&($size[0] + 186)&", y:"&($size[1] + 246)&" is "&$var) ;If $continue = -1 OR $continue = 2 OR $continue = 3 Then Exit If $var <> 16777215 Then Send("!h") EndIf EndIf $didsomething = $didsomething + 1 $count = 0 EndIf If WinExists("Found New Hardware Wizard","This wizard will complete the installation for this device") Then SplashOff() If Not WinActive("Found New Hardware Wizard","This wizard will complete the installation for this device") Then WinActivate("Found New Hardware Wizard","This wizard will complete the installation for this device") If WinActive("Found New Hardware Wizard","This wizard will complete the installation for this device") Then ControlCommand("Found New Hardware Wizard", "", "&Specify a location", "Check", "") ControlCommand("Found New Hardware Wizard", "", "Floppy &disk drives", "UnCheck", "") ControlCommand("Found New Hardware Wizard", "", "&CD-ROM drives", "UnCheck", "") ControlCommand("Found New Hardware Wizard", "", "&Specify a location", "UnCheck", "") Send("!n") EndIf $didsomething = $didsomething + 1 $count = 0 EndIf ; Hardware wizard still open If WinExists("Add/Remove Hardware Wizard","") Then SplashOff() $didsomething = $didsomething + 1 $count = 0 EndIf ; Hardware wizard still open If WinExists("Found New Hardware","") Then SplashOff() $didsomething = $didsomething + 1 $count = 0 EndIf ; Hardware wizard still open If WinExists("Comtrol NS Link Port","") Then SplashOff() $didsomething = $didsomething + 1 $count = 0 EndIf ; If the hardware wizard process is still running then dont exit If ProcessExists($HWPID) Then SplashOff() $didsomething = $didsomething + 1 $count = 0 EndIf If $didsomething = 0 Then If $count >= ($afterwizardwait * 4) Then $done = 1 Else $count = $count + 1 $countdown = int((($afterwizardwait * 4) - $count) /4) Sleep(250) EndIf If $splashon Then ControlSetText("Waiting for Hardware Wizard", "", "Static1", "Waiting to be sure hardware wizard is complete... $countdown seconds remain...") Else SplashTextOn("Waiting for Hardware Wizard", "Waiting to be sure hardware wizard is complete... "&$countdown&" seconds remain...", 550, 50) EndIf EndIf $didsomething = 0 WEnd EndFunc Func SearchFiles ($dir, $search, $searchstring) $searchresult = FileFindFirstFile($dir & "\" & $search) $strings = StringSplit($searchstring, ",") $matching = "" If $searchresult = -1 Then Return 0 EndIf While 1 $file = FileFindNextFile($searchresult) If @error Then ExitLoop if $file <> "." AND $file <> ".." Then $filecontents = FileOpen($dir & "\" & $file,0) If $filecontents = -1 Then Return 0 EndIf $searchfile = 1 While 1 AND $searchfile $line = FileReadLine($filecontents) If @error Then ExitLoop For $stringnum = 1 To ($strings[0]) Step 1 $strings[$stringnum] = StringStripWS ( $strings[$stringnum], 3 ) If StringInStr($line, $strings[$stringnum]) Then $matching = $matching & " " & $file $searchfile = 0 ExitLoop EndIf Next Wend FileClose($filecontents) EndIf WEnd FileClose($searchresult) If $matching = "" Then Return 0 EndIf Return 1 EndFunc Func GetRegistryEntries ($path) $maxrecurse = 5 $keynum = 1 $subkey = 1 dim $count While $subkey $subkey = RegEnumKey($path, $keynum) $regentry = $regentry & $subkey & @CRLF $keynum = $keynum + 1 WEnd Return $regentry EndFunc Func ReturnUnique ($string1, $string2) $array = StringSplit($string2, @CRLF) For $counter = 1 To ($array[0]) Step 1 If $array[$counter] Then $string1 = StringReplace($string1, $array[$counter]&@CRLF, "") EndIf Next $string1 = StringStripCR($string1) Return $string1 EndFunc