lod3n Posted October 25, 2006 Posted October 25, 2006 (edited) expandcollapse popup;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; lod3n's Automated Microsoft Update, beta 1, 10/25/2006 ; ; It (tries to) dl & install the Microsoft Update IE control, goes to Microsoft Update, jumps through ; some frames and clicks some buttons to update Windows and Office. It's really pretty simplistic. ; Requires admin rights and Internet Access to run. ; ; Mad props to DaleHohm for making IE.au3 ; ; Clearly this needs some work: ; 1. It doesn't handle problems with updates at all, ; 2. It doesn't wait around to see if the updates succeeded ; 3. Theoretically, if it knew that the updates succeeded, it could then kill all ; explorer.exe processes and start over until it found out that there were no new updates ; 4. You can't control which updates are installed. maybe you don't want IE7, for instance. ; 5. If microsoft changes their site, the script'll choke. perhaps it could get some values from an INI. ; ; Have fun with it, and post any suggestions or improved code here. Eventually, I'd like to develop ; this into a fairly standalone tool which could be rolled into an automated Updates/Spyware/AV ; computer cleanup script. ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; #include <IE.au3> _IEErrorHandlerRegister ("ComErrFunc") global $COMerrnotify = true ConsoleWrite(@crlf & "lod3n's Automated Microsoft Update starting..." & @crlf) while ProcessExists("iexplore.exe") ProcessClose("iexplore.exe") WEnd ConsoleWrite("Downloading MS Update ActiveX CAB..." & @crlf) InetGet("http://update.microsoft.com/microsoftupdate/v6/V5Controls/en/x86/client/muweb_site.cab","muweb_site.cab") ConsoleWrite("Extracting MS Update ActiveX CAB..." & @crlf) runwait('extract /y /e /l "'&@SystemDir&'" muweb_site.cab',@ScriptDir,@SW_HIDE) ConsoleWrite("Registering MS Update ActiveX..." & @crlf) runwait("regsvr32 /s muweb.dll") $updateurl = "http://update.microsoft.com/microsoftupdate/v6/default.aspx" ConsoleWrite("Opening MS Update..." & @crlf) global $oIE = _IECreate ($updateurl) $oSplashFrame = WaitForFrame($oIE,"http://update.microsoft.com/microsoftupdate/v6/splash.aspx") $oExpressButton = _IEGetObjByName ($oSplashFrame,"aExpress") ConsoleWrite("Clicking Express Update..." & @crlf) _IEAction ($oExpressButton,"click") $oResultFrame = WaitForFrame($oIE,"http://update.microsoft.com/microsoftupdate/v6/resultslist.aspx") $oInstallButton = _IEGetObjByName ($oResultFrame,"eInstallLink") ; checking for disabled Install button suggested by kuh kuh if oInstallButton.disabled = false then ConsoleWrite("Clicking Install..." & @crlf) _IEAction ($oInstallButton,"click") endif ConsoleWrite(@crlf & "lod3n's Automated Microsoft Update is done!" & @crlf) Exit ;;;; my frame spelunker ;;;; Func GetFrameByHref($o_object,$sHref) $COMerrnotify = false for $i = 0 to _IEFrameGetCount($o_object)-1 $frame = _IEFrameGetObjByIndex($o_object,$i) if stringinstr($frame.location.href,$sHref) then $COMerrnotify = true return $frame EndIf $diveframe = GetFrameByHref($frame,$sHref) if isObj($diveframe) then if stringinstr($diveframe.location.href,$sHref) then $COMerrnotify = true return $diveframe EndIf EndIf next return 0 endfunc Func WaitForFrame($o_object,$sHref,$interval = 5000) ConsoleWrite('Waiting for frame with URL containing "' & $sHref & '"...') $foundframe = GetFrameByHref($o_object,$sHref) while not isObj($foundframe) sleep($interval) ConsoleWrite(".") $foundframe = GetFrameByHref($o_object,$sHref) WEnd _IELoadWait($foundframe) consolewrite(" got it!" & @crlf) return $foundframe EndFunc ;;;; my com err func which can be silent, and not halt on errors ;;; Func ComErrFunc() If IsObj($oIEErrorHandler) Then if $COMerrnotify then ConsoleWrite("--> ComErrFunc: COM Error Encountered in " & @ScriptName & @CR) ConsoleWrite("----> Scriptline = " & $oIEErrorHandler.scriptline & @CR) ConsoleWrite("----> Number Hex = " & Hex($oIEErrorHandler.number, 8) & @CR) ConsoleWrite("----> Number = " & $oIEErrorHandler.number & @CR) ConsoleWrite("----> Win Description = " & StringStripWS($oIEErrorHandler.WinDescription, 2) & @CR) ConsoleWrite("----> Description = " & StringStripWS($oIEErrorHandler.description, 2) & @CR) ConsoleWrite("----> Source = " & $oIEErrorHandler.Source & @CR) ConsoleWrite("----> Help File = " & $oIEErrorHandler.HelpFile & @CR) ConsoleWrite("----> Help Context = " & $oIEErrorHandler.HelpContext & @CR) ConsoleWrite("----> Last Dll Error = " & $oIEErrorHandler.LastDllError & @crlf) EndIf $HexNumber = Hex($oIEErrorHandler.number, 8) SetError($HexNumber) Else SetError(1) EndIf Return 0 EndFunc ;;;; salvaged old IE.au3 functions for frame mgmt ;;;;; Func _IEFrameGetCount($o_object) $oDoc = _IEDocGetObj($o_object) If IsObj($oDoc) Then SetError(0) Return $oDoc.parentwindow.frames.length Else SetError(1) Return 0 EndIf EndFunc Func _IEFrameGetObjByIndex($o_object, $i_index) If IsObj($o_object.document.parentwindow.frames.item ($i_index)) Then SetError(0) Return $o_object.document.parentwindow.frames.item ($i_index) Else SetError(1) Return 0 EndIf EndFunc Edited October 26, 2006 by lod3n [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]
kuh_kuh Posted October 26, 2006 Posted October 26, 2006 other : expandcollapse popup;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; lod3n's Automated Microsoft Update, beta 1, 10/25/2006 ; ; It (tries to) dl & install the Microsoft Update IE control, goes to Microsoft Update, jumps through ; some frames and clicks some buttons to update Windows and Office. It's really pretty simplistic. ; Requires admin rights and Internet Access to run. ; ; Mad props to DaleHohm for making IE.au3 ; ; Clearly this needs some work: ; 1. It doesn't handle problems with updates at all, ; 2. It doesn't wait around to see if the updates succeeded ; 3. Theoretically, if it knew that the updates succeeded, it could then kill all ; explorer.exe processes and start over until it found out that there were no new updates ; 4. You can't control which updates are installed. maybe you don't want IE7, for instance. ; 5. If microsoft changes their site, the script'll choke. perhaps it could get some values from an INI. ; ; Have fun with it, and post any suggestions or improved code here. Eventually, I'd like to develop ; this into a fairly standalone tool which could be rolled into an automated Updates/Spyware/AV ; computer cleanup script. ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; #include <IE.au3> _IEErrorHandlerRegister ("ComErrFunc") global $COMerrnotify = true while ProcessExists("iexplore.exe") ProcessClose("iexplore.exe") WEnd $updateurl = "http://windowsupdate.microsoft.com/" global $oIE = _IECreate ($updateurl,0,1) $oSplashFrame = WaitForFrame($oIE,"http://update.microsoft.com/microsoftupdate/v6/splash.aspx") $oExpressButton = _IEGetObjByName ($oSplashFrame,"aExpress") _IEAction ($oExpressButton,"click") $oResultFrame = WaitForFrame($oIE,"http://update.microsoft.com/microsoftupdate/v6/resultslist.aspx") $oInstallButton = _IEGetObjByName ($oResultFrame,"eInstallLink") $inhalt = _IEBodyReadHTML ( $oInstallButton ) $weiter =StringInStr ( $inhalt, "BUTTON id=eInstallLink disabled ") if $weiter <>0 Then _IEAction ($oInstallButton,"click") Else _IEQuit($oIE) EndIf Exit ;;;; my frame spelunker ;;;; Func GetFrameByHref($o_object,$sHref) $COMerrnotify = false for $i = 0 to _IEFrameGetCount($o_object)-1 $frame = _IEFrameGetObjByIndex($o_object,$i) if stringinstr($frame.location.href,$sHref) then $COMerrnotify = true return $frame EndIf $diveframe = GetFrameByHref($frame,$sHref) if isObj($diveframe) then if stringinstr($diveframe.location.href,$sHref) then $COMerrnotify = true return $diveframe EndIf EndIf next return 0 endfunc Func WaitForFrame($o_object,$sHref,$interval = 50000) $foundframe = GetFrameByHref($o_object,$sHref) while not isObj($foundframe) sleep($interval) ConsoleWrite(".") $foundframe = GetFrameByHref($o_object,$sHref) WEnd _IELoadWait($foundframe) return $foundframe EndFunc ;;;; my com err func which can be silent, and not halt on errors ;;; Func ComErrFunc() If IsObj($oIEErrorHandler) Then if $COMerrnotify then ConsoleWrite("--> ComErrFunc: COM Error Encountered in " & @ScriptName & @CR) ConsoleWrite("----> Scriptline = " & $oIEErrorHandler.scriptline & @CR) ConsoleWrite("----> Number Hex = " & Hex($oIEErrorHandler.number, 8) & @CR) ConsoleWrite("----> Number = " & $oIEErrorHandler.number & @CR) ConsoleWrite("----> Win Description = " & StringStripWS($oIEErrorHandler.WinDescription, 2) & @CR) ConsoleWrite("----> Description = " & StringStripWS($oIEErrorHandler.description, 2) & @CR) ConsoleWrite("----> Source = " & $oIEErrorHandler.Source & @CR) ConsoleWrite("----> Help File = " & $oIEErrorHandler.HelpFile & @CR) ConsoleWrite("----> Help Context = " & $oIEErrorHandler.HelpContext & @CR) ConsoleWrite("----> Last Dll Error = " & $oIEErrorHandler.LastDllError & @crlf) EndIf $HexNumber = Hex($oIEErrorHandler.number, 8) SetError($HexNumber) Else SetError(1) EndIf Return 0 EndFunc ;;;; salvaged old IE.au3 functions for frame mgmt ;;;;; Func _IEFrameGetCount($o_object) $oDoc = _IEDocGetObj($o_object) If IsObj($oDoc) Then SetError(0) Return $oDoc.parentwindow.frames.length Else SetError(1) Return 0 EndIf EndFunc Func _IEFrameGetObjByIndex($o_object, $i_index) If IsObj($o_object.document.parentwindow.frames.item ($i_index)) Then SetError(0) Return $o_object.document.parentwindow.frames.item ($i_index) Else SetError(1) Return 0 EndIf EndFunc the most kommin from lod3n
lod3n Posted October 26, 2006 Author Posted October 26, 2006 Kuh Kuh, So, if the Install Updates button is disabled, quit? Ah, I see, that's what it does when you've installed all of the updates. No need to click in that case. I have added a check for that in the code. If you could edit your post, and trim it down to just the part you've suggested, it might make this page easier to read. Your call. Thanks! [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now