#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=WSUSFix.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs
WSUSFix
This application will repair WSUS issues that may have been caused by the machine being imaged.
Referrenced from:
http://www.wsuswiki.com/ClientFAQ
http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Server/2003_Server/Q_23550840.html
http://blog.netnerds.net/2006/12/wsus-force-registration-of-clients-that-are-not-showing-up/
Alex Belenkiy
ab@nyitsupport.com
07/15/2009
#ce
If Not IsAdmin() then Exit ; check for admin rights
if @OSVersion <> "WIN_XP" then Exit ; Only install on Windows XP
if FileExists("c:\windows\WSUS\WSUSFixComplete.txt") then Exit
dim $error, $File, $log, $logText
$command = RunWait(@ComSpec & " /c " & "net stop wuauserv")
if @error then
call("Logger", "net stop wuauserv FAILED")
$error = 1
Else
call("Logger", "net stop wuauserv SUCCESSFUL")
EndIf
Call("RegFix", "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate", "AccountDomainSid")
Call("RegFix", "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate", "PingID")
Call("RegFix", "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate", "SusClientId")
Call("RegFix", "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update", "LastWaitTimeout")
Call("RegFix", "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update", "DetectionStartTime")
Call("RegFix", "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update", "NextDetectionTime")
Call("RegFix", "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update", "AUState")
$command = RunWait(@ComSpec & " /c " & "net start wuauserv")
if @error then
call("Logger", "net start wuauserv FAILED")
$error = 1
Else
call("Logger", "net start wuauserv SUCCESSFUL")
EndIf
$command = RunWait(@ComSpec & " /c " & "wuauclt /resetauthorization /detectnow")
if @error then
call("Logger", "wuauclt /resetauthorization /detectnow FAILED")
$error = 1
Else
call("Logger", "wuauclt /resetauthorization /detectnow SUCCESSFUL")
EndIf
if $error <> 1 then ; install completed successfully don't run again.
$File = FileOpen("c:\windows\WSUS\WSUSFixComplete.txt",9)
call ("Logger", "WSUS Fix completed successfully")
Else ; install did not complete successfully, write a log and allow for another try
call ("Logger", "WSUS Fix encountered errors. Will try again at next startup.")
EndIf
Func Logger($logText) ; write a log
$log = FileOpen(@ScriptDir & "\Logs\" & @ComputerName & ".log", 9)
if not @error Then
FileWriteLine($log, @CRLF & $logText & " - " & @MON & "/" & @MDAY & "/" & @YEAR & " - " & @HOUR & ":" & @MIN)
FileClose($log)
EndIf
EndFunc
Func RegFix($RegKey, $RegVal)
$Command = RegRead($RegKey, $RegVal)
if not @error Then
call("Logger", "RegRead " & $RegKey & " " & $RegVal & " " & "LOCATED")
$Command = RegDelete($RegKey, $RegVal)
if @error then
$error = 1
call("Logger", "RegDelete " & $RegKey & " " & $RegVal & " " & "FAILED")
Else
call("Logger", "RegDelete " & $RegKey & " " & $RegVal & " " & "SUCCESSFUL")
EndIf
Else
call("Logger", "REGREAD " & $RegKey & " " & $RegVal & " " & "NOT FOUND")
EndIf
EndFunc