Jump to content

Windows Update Fix


2tim3_16
 Share

Recommended Posts

Too often we come across computers that aren't getting automatic updates, even though they're turned on via GP. If we try running Windows Updates manually on these computers, we get various error codes, most of which don't appear on Microsofts KB. So, after doing some research on various fourms, I put together the following script. So far it has corrected every WU error we have run across.

Hope it's usefull to someone!

;If Internet Explorer is open, close it.
If ProcessExists("iexplore.exe") Then ProcessClose("iexplore.exe")

;Stop the Automatic Updates service.
Run('net stop "Automatic Updates"')
Sleep(3000)

;Check the version of iexplore.exe, then clear the Internet Cache.
If StringLeft(FileGetVersion(@ProgramFilesDir & "\Internet Explorer\iexplore.exe"), 1) = "7" Then
    
    Run('control inetcpl.cpl')
    WinWait('Internet Properties')
    ControlClick('Internet Properties', '', 'Button4')
    WinWait('Delete Browsing History')
    ControlClick('Delete Browsing History', '', 'Button1')
    WinWait('Delete Files')
    ControlClick('Delete Files', '', 'Button1')
    WinWait('Delete Browsing History')
    ControlClick('Delete Browsing History', '', 'Button7')
    WinWait('Internet Properties')
    ControlClick('Internet Properties', '', 'Button12')
    
ElseIf StringLeft(FileGetVersion(@ProgramFilesDir & "\Internet Explorer\iexplore.exe"), 1) = "6" Then
    
    Run('control inetcpl.cpl')
    WinWait('Internet Properties')
    ControlClick('Internet Properties', '', 'Button7')
    WinWait('Delete Files')
    ControlClick('Delete Files', '', 'Button1')
    WinWait('Delete Files')
    ControlClick('Delete Files', '', 'Button2')
    WinWait('Internet Properties')
    ControlClick('Internet Properties', '', 'Button15')
    
Else
    Exit
EndIf

;Delete the Windows Update Log file(s)
If FileExists(@WindowsDir & "\WindowsUpdate.log") Then FileDelete(@WindowsDir & "\WindowsUpdate.log")
If FileExists(@WindowsDir & "\Windows Update.log") Then FileDelete(@WindowsDir & "\Windows Update.log")

;Delete the SoftwareDistribution folder.
DirRemove(@WindowsDir & "\SoftwareDistribution", 1)
Sleep(3000)

#cs - Optional dll reregistrations: enable as needed. (See http://mygreenpaste.blogspot.com/2006/08/error-0x8ddd0009-with-microsoft-update.html)
;Reregister MSXML3.dll
Run("regsvr32 msxml3.dll")
WinWait("RegSvr32", "DllRegisterServer in msxml3.dll succeeded.")
ControlClick("RegSvr32", "DllRegisterServer in msxml3.dll succeeded.", 'Button1')

;Reregister wuapi.dll
Run("regsvr32 wuapi.dll")
WinWait("RegSvr32", "DllRegisterServer in wuapi.dll succeeded.")
ControlClick("RegSvr32", "DllRegisterServer in wuapi.dll succeeded.", 'Button1')

;Reregister wups.dll
Run("regsvr32 wups.dll")
WinWait("RegSvr32", "DllRegisterServer in wups.dll succeeded.")
ControlClick("RegSvr32", "DllRegisterServer in wups.dll succeeded.", 'Button1')

;Reregister wuaueng.dll
Run("regsvr32 wuaueng.dll")
WinWait("RegSvr32", "DllRegisterServer in wuaueng.dll succeeded.")
ControlClick("RegSvr32", "DllRegisterServer in wuaueng.dll succeeded.", 'Button1')

;Reregister wuaueng1.dll
Run("regsvr32 wuaueng1.dll")
WinWait("RegSvr32", "DllRegisterServer in wuaueng1.dll succeeded.")
ControlClick("RegSvr32", "DllRegisterServer in wuaueng1.dll succeeded.", 'Button1')

;Reregister wucltui.dll
Run("regsvr32 wucltui.dll")
WinWait("RegSvr32", "DllRegisterServer in wucltui.dll succeeded.")
ControlClick("RegSvr32", "DllRegisterServer in wucltui.dll succeeded.", 'Button1')

;Reregister wuweb.dll
Run("regsvr32 wuweb.dll")
WinWait("RegSvr32", "DllRegisterServer in wuweb.dll succeeded.")
ControlClick("RegSvr32", "DllRegisterServer in wuweb.dll succeeded.", 'Button1')

;Reregister qmgr.dll
Run("regsvr32 qmgr.dll")
WinWait("RegSvr32", "DllRegisterServer in qmgr.dll succeeded.")
ControlClick("RegSvr32", "DllRegisterServer in qmgr.dll succeeded.", 'Button1')

;Reregister qmgrprxy.dll
Run("regsvr32 qmgrprxy.dll")
WinWait("RegSvr32", "DllRegisterServer in qmgrprxy.dll succeeded.")
ControlClick("RegSvr32", "DllRegisterServer in qmgrprxy.dll succeeded.", 'Button1')

;Reregister msxml3.dll
Run("regsvr32 msxml3.dll")
WinWait("RegSvr32", "DllRegisterServer in jscript.dll succeeded.")
ControlClick("RegSvr32", "DllRegisterServer in jscript.dll succeeded.", 'Button1')
#ce

;Start the Automatic Updates service.
Run('net start "Automatic Updates"')
Sleep(3000)

;Launch the Microsoft Update website.
Run(@SystemDir & "\rundll32.exe " & @SystemDir & "\muweb.dll,LaunchMUSite")

Edit: Fixed "Buttin1"

Edit: Replaced paths with macros

Edited by 2tim3_16
Link to comment
Share on other sites

You might want to add these lines

RunWait(@SystemDir&"\proxycfg.exe -d") ; defaults proxy cfg
RunWait(@comspec & " /c net stop wuauserv") ; stops autoupdate service, may conflict
DirRemove (@WindowsDir&"\SoftwareDistribution",1) ; clears out any corrupted downloads

That was my general purpose windows update fixer for some time.

Edit: ahh, I see you've pretty much covered the bottom two commands. Sorry about that. And defaulting the proxy config isn't always a great idea unless you are setting it correctly via GP anyway.

Edited by lod3n

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Link to comment
Share on other sites

You might want to add these lines

RunWait(@SystemDir&"\proxycfg.exe -d") ; defaults proxy cfg
RunWait(@comspec & " /c net stop wuauserv") ; stops autoupdate service, may conflict
DirRemove (@WindowsDir&"\SoftwareDistribution",1) ; clears out any corrupted downloads

That was my general purpose windows update fixer for some time.

Edit: ahh, I see you've pretty much covered the bottom two commands. Sorry about that. And defaulting the proxy config isn't always a great idea unless you are setting it correctly via GP anyway.

We do have a proxy connection set through GP, and so far that hasn't seemed to be an issue. Thanks for the input, though!

Yesterday was the first time I'd come across a computer that I needed to reregister any dll's. Prior to that, just running everything else worked.

Link to comment
Share on other sites

Thnx

but if i were you i would channge c:\windows into @WindowsDir

c:\windows\system32 into @SystemDir

c:\program files into @ProgramFilesDir

Emiel

I would agree on that one. Fantastic script though! I'll definitely be using it.

Link to comment
Share on other sites

Thnx

but if i were you i would channge c:\windows into @WindowsDir

c:\windows\system32 into @SystemDir

c:\program files into @ProgramFilesDir

Emiel

1.) Perfect point! I boot from C:\ but XP is installed on F:\ ("@WindowsDir" = F:\Windows)

We're rare, but some of us do it :D

2.) yup, first post.. just wanted to add that autoit is the coolest thing I've seen in a ~long~ time. Makes things much easier... Props and i can't believe i didn't find it sooner :D

just got it yesterday and already made a bot for AQ :) just goofin around get'n used to it. (no, not the major hacks.. don't msg for them lol)

3.) Sweet script! wish i had it when I was help desk...

Link to comment
Share on other sites

  • 4 weeks later...

Good job 2tim3_16!

But you can optimize some things: :whistle:

stop/start the service for all languages with

net stop/start wuauserv

Don't check just doit:

ProcessClose("iexplore.exe")
FileDelete(@WindowsDir & "\WindowsUpdate.log")

Clear cache ONLY for IE7:

RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8

'Cause you let click every button you can use for silent DLL reregistrations:

;Reregister MSXML3.dll
RunWait("regsvr32 /s msxml3.dll")
;Reregister wuapi.dll
Run("regsvr32 /s wuapi.dll")
;Reregister wups.dll
Run("regsvr32 /s wups.dll")
;Reregister wuaueng.dll
Run("regsvr32 /s wuaueng.dll")
;Reregister wuaueng1.dll
Run("regsvr32 /s wuaueng1.dll")
;Reregister wucltui.dll
Run("regsvr32 /s wucltui.dll")
;Reregister wuweb.dll
Run("regsvr32 /s wuweb.dll")
;Reregister qmgr.dll
Run("regsvr32 /s qmgr.dll")
;Reregister qmgrprxy.dll
Run("regsvr32 /s qmgrprxy.dll")
;Reregister jscript.dll
Run("regsvr32 /s jscript.dll") ;CORRECTED
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...