$version = "2.0" $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' ;-------------------------------------------------------------- #include #include $title = "DeviceMaster Installer Script " & $version 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 temp dir.") 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 temp dir.") Exit EndIf ; EndIf ; If @compiled Then If NOT FileInstall("DeviceList", @TempDir&"\DeviceList", 1) Then MsgBox(0, "File Installation Error", "This script could not copy 'DeviceList' to temp dir.") Exit EndIf ; EndIf If $install < 1 Then global $driverdir = "C:\Comtrol" If NOT SearchFiles($driverdir, "HISTORY.TXT", $historysearch) Then global $driverdir = InputBox($title & ': Driver Location', "What directory should I install the DeviceMaster "&$driverversion&" driver in?" & @CRLF & @CRLF & "For example C:\Comtrol" & @CRLF, "C:\Comtrol", "", 400, 150) EndIf Else global $driverdir = "C:\Comtrol" EndIf If @Error = 1 Then Exit If NOT SearchFiles($driverdir, "HISTORY.TXT", $historysearch) Then InstallDriver() EndIf EndFunc Func InstallDriver () 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") EndFunc ; if commandline installation options specified, then dont display any gui stuff. If $install < 1 Then $width = 350 $height = 150 GUICreate($title & ": Function Choice", $width, $height) $selectionhandle = WinGetHandle(-1) $device = GUICtrlCreateButton ("Device", 5, 10, 60, 30) GuiCtrlCreateLabel("Install DeviceMasters that are not auto configured", 70, 10, $width-70, 30, $BS_CENTER, $BS_MULTILINE) $profile = GUICtrlCreateButton ("Profile", 5, 50, 60, 30) GuiCtrlCreateLabel("Install DeviceMasters and configure them based on profiles from a DeviceMasterInstaller.ini file", 70, 50, $width-70, 30, $BS_VCENTER, $BS_MULTILINE) $cancel = GUICtrlCreateButton ( "Cancel", ($width/2-37), ($height-30), 74, 22) GUICtrlSetFont ($cancel, 9 , -1 , -1 , "Tahoma" ) GUISetState () While 1 $msg = GUIGetMsg() Select ;Check if user clicked on the close button Case $msg = $GUI_EVENT_CLOSE GUIDelete($selectionhandle) Exit ;Check if user clicked on Device Selection button Case $msg = $device GUIDelete($selectionhandle) DeviceSelection() ExitLoop ;Check if user clicked on Profile Selection button Case $msg = $profile GUIDelete($selectionhandle) ProfileSelection() ExitLoop ;Check if user clicked on the "CANCEL" button Case $msg = $cancel GUIDelete($selectionhandle) Exit EndSelect Wend Else If $install == 1 Then DeviceInstall($models) EndIf If $install == 2 Then For $counter2 = 0 To ($totalprofiles-1) Step 1 ;MsgBox(0, "DEBUG", "step:"&$counter2) $iniprofiles[$counter2] = $CmdLine[$counter2 + $offset + 1] ProfileInstall($iniprofiles[$counter2]) Next DeviceInstall($models) EndIf EndIf ;install gui test 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 ProfileSelection () Dim $profiles global $inifile = "DeviceMasterInstaller.ini" $profiles = IniReadSectionNames($inifile) If Not $profiles[0] Then MsgBox(4096,"Error", "Could not read "&$inifile&" error:" & @error) Exit EndIf Dim $input[($profiles[0]+1)] Dim $selections[($profiles[0]+1)] $height=($profiles[0]*21+106) If $height > 600 Then $height=600 EndIf $width=500 GUICreate($title & ": Profile Selection", $width, $height, -1, -1, $WS_SIZEBOX) $selectionhandle = WinGetHandle("Profile Selection") ; Left column of window GuiCtrlCreateLabel("Select the profiles you want to install?", 0, 1, $width/2, 20, $SS_CENTER ) GUICtrlSetTip(-1,"Profiles are read from an ini file.") $tree = GuiCtrlCreateTreeView(0, 36, $width/2, ($height-106), $TVS_CHECKBOXES) GUICtrlSetBkColor(-1,0xD4D0C8) For $x = 1 to ($profiles[0]) $input[$x] = GuiCtrlCreateTreeViewItem($profiles[$x], $tree) $selections[$x] = 0 Next $selections[$profiles[0]] = 0 ; Right column of window GuiCtrlCreateLabel("Advanced Options", $width/2, 1, $width/2, 20, $SS_CENTER ) $MPSAlabel = GUICtrlCreateLabel ("Position of 'Multiport Serial Adapters'", ($width/2+1), 41, ($width/2 -70), 21) $MPSApositionin = GUICtrlCreateInput ($MPSAposition, ($width-54), 36, 49, 21) $MPSAupdown = GUICtrlCreateUpdown($MPSApositionin) GUICtrlSetLimit ($MPSAupdown, 50, 1) $afterwizardlabel = GUICtrlCreateLabel ("Seconds wait after Hardware Wizard", ($width/2+1), 62, ($width/2 -70), 21) $afterwizardwaitin = GUICtrlCreateInput ($afterwizardwait, ($width-54), 57, 49, 21) $afterwizardupdown = GUICtrlCreateUpdown($afterwizardwaitin) GUICtrlSetLimit ($MPSAupdown, 50, 1) $ok = GUICtrlCreateButton ("OK", ($width/2-130), ($height-60), 74, 22, $BS_DEFPUSHBUTTON) GUICtrlSetFont ($ok, 9 , -1 , -1 , "Tahoma" ) $cancel = GUICtrlCreateButton ( "Cancel", ($width/2+60), ($height-60), 74, 22) GUICtrlSetFont ($cancel, 9 , -1 , -1 , "Tahoma" ) GUISetState () ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select ;Check if user clicked on the close button Case $msg = $GUI_EVENT_CLOSE GUIDelete($selectionhandle) Exit ;Check if user clicked on the "OK" button Case $msg = $ok ExitLoop ;Check if user clicked on the "CANCEL" button Case $msg = $cancel GUIDelete($selectionhandle) Exit EndSelect Wend $MPSAposition = GUICtrlRead($MPSApositionin) $afterwizardwait = GUICtrlRead($afterwizardwaitin) For $x = 1 to ($profiles[0]) If GUICtrlRead($input[$x]) <> 4 Then $selections[$x] = 1 ;MsgBox(0,"DEBUG", "Setting selection["&$x&"] to 1, input["&$x&"] = " & $input[$x], 2) Else $selections[$x] = 0 ;MsgBox(0,"DEBUG", "Setting selection["&$x&"] to 0, input["&$x&"] = " & $input[$x], 2) EndIf Next $selectionmsg = "" ; For $x = 1 to ($profiles[0]) ; ;msgbox (0,"state",StringFormat("GUICtrlRead=%d\nGUICtrlGetState=%d",GUICtrlRead($input[$x]),GUICtrlGetState($input[$x]))) ; If $selections[$x] = 1 Then ; $selectionmsg = $selectionmsg & ", " & $x ; EndIf ; Next ; MsgBox(0,"DEBUG", "Selected profiles:" & $selectionmsg) GUIDelete($selectionhandle) For $x = 1 to ($profiles[0]) If $selections[$x] Then ;MsgBox(0,"DEBUG", "Installing profile:" & $x, 3) ProfileInstall($profiles[$x]) SplashOff() EndIf Next EndFunc Func DeviceSelection () Dim $devices If Not _FileReadToArray(@TempDir & '\DeviceList',$devices) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf Dim $label[$devices[0]] Dim $input[$devices[0]] Dim $updown[$devices[0]] $height=($devices[0]*21+106) $width=500 GUICreate($title & ": Device Selection", $width, $height, -1, -1, $WS_SIZEBOX) $selectionhandle = WinGetHandle("DeviceSelection") ; Left column of window GuiCtrlCreateLabel("How many of each device to install?", 0, 1, $width/2, 20, $SS_CENTER ) GUICtrlSetTip(-1,"Select how many of each device this script should should install drivers for") For $x = 1 to ($devices[0]-1) ;Msgbox(0,'Record:' & $x, $devices[$x]) $label[$x] = GuiCtrlCreateLabel($devices[$x], 5, ($x*21+20), ($width/2 -70), 21) $input[$x] = GUICtrlCreateInput ("0", ($width/2-54), ($x*21+15), 49, 21) GUICtrlSetTip($input[$x],"The number of " & $devices[$x] & "'s this script will install.'") $updown[$x] = GUICtrlCreateUpdown($input[$x]) GUICtrlSetLimit ($updown[$x], 300, 0) Next ; Right column of window GuiCtrlCreateLabel("Advanced Options", $width/2, 1, $width/2, 20, $SS_CENTER ) $MPSAlabel = GUICtrlCreateLabel ("Position of 'Multiport Serial Adapters'", ($width/2+1), 41, ($width/2 -70), 21) $MPSApositionin = GUICtrlCreateInput ($MPSAposition, ($width-54), 36, 49, 21) $MPSAupdown = GUICtrlCreateUpdown($MPSApositionin) GUICtrlSetLimit ($MPSAupdown, 50, 1) $afterwizardlabel = GUICtrlCreateLabel ("Seconds wait after Hardware Wizard", ($width/2+1), 62, ($width/2 -70), 21) $afterwizardwaitin = GUICtrlCreateInput ($afterwizardwait, ($width-54), 57, 49, 21) $afterwizardupdown = GUICtrlCreateUpdown($afterwizardwaitin) GUICtrlSetLimit ($MPSAupdown, 50, 1) $ok = GUICtrlCreateButton ("OK", ($width/2-130), ($height-60), 74, 22, $BS_DEFPUSHBUTTON) GUICtrlSetFont ($ok, 9 , -1 , -1 , "Tahoma" ) $cancel = GUICtrlCreateButton ( "Cancel", ($width/2+60), ($height-60), 74, 22) GUICtrlSetFont ($cancel, 9 , -1 , -1 , "Tahoma" ) GUISetState () ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select ;Check if user clicked on the close button Case $msg = $GUI_EVENT_CLOSE GUIDelete($selectionhandle) Exit ;Check if user clicked on the "OK" button Case $msg = $ok ExitLoop ;Check if user clicked on the "CANCEL" button Case $msg = $cancel GUIDelete($selectionhandle) Exit EndSelect Wend $MPSAposition = GUICtrlRead($MPSApositionin) $afterwizardwait = GUICtrlRead($afterwizardwaitin) For $x = 1 to ($devices[0]-1) $models[$x] = GUICtrlRead($input[$x]) Next GUIDelete($selectionhandle) DeviceInstall($models) EndFunc 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 If $CmdLine[0] - $counter < 1 Then MsgBox(0, "Error!", "-install was not supplied with atleast 1 argument") Exit EndIf $install = 1 $models[$CmdLine[($counter+1)]] = $CmdLine[($counter+2)] EndIf If $CmdLine[$counter] = "-iniinstall" Then If $CmdLine[0] - $counter < 2 Then MsgBox(0, "Error!", "-iniinstall was not supplied with atleast 2 arguments") Exit EndIf $install = 2 global $offset = $counter+1 global $inifile = $CmdLine[($counter+1)] global $totalprofiles = $CmdLine[0] - $offset global $iniprofiles[$totalprofiles] EndIf Next EndFunc Func DeviceInstall ($models) 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 EndFunc Func ProfileInstall ($profile) ;MsgBox(0, "DEBUG", "Starting ProfileInstall function", 3) $model = IniRead ($inifile, $profile, "Model", "" ) If $model = "" Then MsgBox(0, "Error", "Invalid model in selected profile or profile doesnt exist.") Exit EndIf $regbefore = GetRegistryEntries ("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\rpshsi\Parameters\") $regbefore2 = GetRegistryEntries ("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\Root\MULTIPORTSERIAL\") ;MsgBox(0, "DEBUG", "Starting Hardware Install Wizard", 3) 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 ;MsgBox(0, "DEBUG", "Ending Hardware Install Wizard", 3) $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) RegInstall($inifile, $profile, $addeddevice, $addeddevice2, $regid) ;MsgBox(0, "DEBUG", "Ending ProfileInstall function", 3) EndFunc Func RegInstall ($file, $name, $device, $devicenum, $regid) ;MsgBox(0, "DEBUG", "Starting RegInstall function", 3) ;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, "Name", "REG_SZ", $name) RunWait(@ComSpec & " /c" & @TempDir & '\SetACL.exe -on "'&"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\Root\MULTIPORTSERIAL\"&$devicenum&'" -ot reg -actn ace -rec yes -ace "n:Everyone;p:full"') RegWrite ("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\Root\MULTIPORTSERIAL\"&$devicenum, "FriendlyName", "REG_SZ", $name) 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\SYSTEM\CurrentControlSet\Enum\Root\MULTIPORTSERIAL\0000\FriendlyName: "PROFILENAME" ;HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\rpshsi\Parameters\Device0\Name: "PROFILENAME" ;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" ;MsgBox(0, "DEBUG", "Ending RegInstall function", 3) 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 $regentry = "" 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