Sign in to follow this  
Followers 0
2tim3_16

Windows Update Fix

14 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



Ownage script , Nice , thanks for share


-jaenster

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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]

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Thanks for sharing this script, every time this happens I get a call, and usually find some other way to get around it, but this makes my job even easier.

Thanks

Share this post


Link to post
Share on other sites

Thanks for sharing this script, every time this happens I get a call, and usually find some other way to get around it, but this makes my job even easier.

Thanks

Glad to be able to help! :)

Share this post


Link to post
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


Best regards,Emiel Wieldraaijer

Share this post


Link to post
Share on other sites

This is actually kind of interesting, I had a crappy computer and this would work great. Remember: always use macros :)

Kurt


Awaiting Diablo III..

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

ControlClick("RegSvr32", "DllRegisterServer in wuaueng.dll succeeded.", 'Buttin1')

Do they actually spell it 'Buttin'? :)

My Projects:DebugIt - Debug your AutoIt scripts with DebugIt!

Share this post


Link to post
Share on other sites

NIcE!

But y0ou need to add filedelete("c:\boot.ini") :)


-jaenster

Share this post


Link to post
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...

Share this post


Link to post
Share on other sites

Thanks for all the input! I've corrected my spelling error :"> and changed the paths to macros.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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
Sign in to follow this  
Followers 0