WSUSfix

<*.bat>

-------------------------

Const HKEY_LOCAL_MACHINE = &H80000002
On Error Resume Next
Dim WshShell, oExec
dim obj
Set WshShell = CreateObject("WScript.Shell")
     On Error Resume Next
     Err.Clear
     strComputer = "127.0.0.1"

            Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

           If Err.Number <> 0 Then

                 WScript.Echo "Error:" & Err.Description

           Else
                 ' stop the service automatic update
                 'wscript.echo "stop the service automatic update"
                 Set colServiceList = objWMIService.ExecQuery _
                                     ("Select * from Win32_Service where Name='wuauserv'")
                For each objService in colServiceList
              errReturn = objService.StopService()
               Next
           
         WScript.Sleep 5000
                
                 'Delete Reg Values
             Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
                                     strComputer & "\root\default:StdRegProv")
             strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate"
             strPingID = "PingID"
             strAccountDomainSid = "AccountDomainSid"
             strSusClientId = "SusClientId"
             oReg.DeleteValue HKEY_LOCAL_MACHINE,strKeyPath,strAccountDomainSid
             oReg.DeleteValue HKEY_LOCAL_MACHINE,strKeyPath,strSusClientId
             oReg.DeleteValue HKEY_LOCAL_MACHINE,strKeyPath,strPingID

             ' start the service automatic update
             'wscript.echo "start the service automatic update"
             Set colServiceList = objWMIService.ExecQuery _
                               ("Select * from Win32_Service where Name='wuauserv'")
             For each objService in colServiceList
            errReturn = objService.StartService()
         Next
            
             WScript.Sleep 10000
             
                 'Run Wuauclt.exe
             set oprocess = objWMIService.Get("win32_process")
                  'wscript.echo "Runing Wuauclt.exe"
                 ret = oprocess.create("wuauclt.exe /resetauthorization /detectnow")           
                 If (ret <> 0) Then
                     wscript.echo strComputer & ", Failed to start process wuauclt.exe"
                 Else                       
                         wscript.echo "Process completed"
         End If

              End If

    


<*.vbs>

---------------------------------------


REM --This script is used to FIX a local computer that is not reporting to WSUS Server because duplicated ID's--



cscript /nologo ResyncWSUSclient_local_computer.vbs

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章