I have a script I found and modified. I need it to stop the wuauserv service change some reg settings then start the service on a remote computer. The script stops/starts the remote service but does not change the remote computers reg settings. I have done some research on this but it is a little over my head. Can someone point me in the right direction.
-----------------------------------------------------------
Set WSHShell = WScript.CreateObject("WScript.Shell")
Set WNetwork = Wscript.CreateObject("Wscript.Network")
On Error Resume Next
'Query for target computer
strComputer = InputBox("Please enter the name of the computer you want to reset.", "Reset SUS Client Updates", WNetwork.ComputerName)
If strComputer = "" Then Wscript.Quit
strComputer = Ucase(strComputer)
'Stop the Automatic Updates service
Set oService = GetObject("WinMgmts:{impersonationLevel=impersonate}!//" & strComputer & "/root/cimv2:Win32_Service.Name='wuauserv'")
If Err = 462 Then
MsgBox "Computer " & strComputer & " does not exist.", 16, "Error"
Wscript.Quit
End If
If oService.StartMode = "Disabled" Then
MsgBox "The Automatic Updates service on " & strComputer & " is disabled." & vbCRLF & "No changes have been made.", 16, "Automatic Updates Error"
Wscript.Quit
Else
If oService.StartMode = "Manual" Then
Auto = MsgBox("The Automatic Updates service on " & strComputer & " is set to Manual." & vbCRLF & "Do you want to set it to Automatic?", 36, "Automatic Updates Service")
If Auto = vbYes Then oService.ChangeStartMode("Automatic")
End If
oService.StopService
End If
'Wait until the service stops
Do
Set oService = GetObject("WinMgmts:{impersonationLevel=impersonate}!//" & strComputer & "/root/cimv2:Win32_Service.Name='wuauserv'")
Loop Until oService.State = "Stopped"
'Reset the AUState to detect pending updates
WSHShell.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\AUState", 2, "REG_DWORD"
WshShell.RegWrite "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU\NoAutoUpdate", "0", "REG_DWORD"
'Force Automatic Updates
WSHShell.RegWrite "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU\AUOptions", "4", "REG_DWORD"
WSHShell.RegWrite "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\AUOptions", "4", "REG_DWORD"
WSHShell.RegDelete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\DetectionStartTime"
WSHShell.RegDelete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\NextDetectionTime"
WSHShell.RegDelete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\ScheduledInstallDate"
WSHShell.RegDelete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\ScheduledInstallDay"
WSHShell.RegDelete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\ScheduledInstallTime"
'Delete the LastWaitTimeOut value if it exists
WSHShell.RegDelete "HKLM\Software\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\LastWaitTimeout"
'Start the Automatic Updates service
Set oService = GetObject("WinMgmts:{impersonationLevel=impersonate}!//" & strComputer & "/root/cimv2:Win32_Service.Name='wuauserv'")
oService.StartService
'Wait until the service starts
Do
Set oService = GetObject("WinMgmts:{impersonationLevel=impersonate}!//" & strComputer & "/root/cimv2:Win32_Service.Name='wuauserv'")
Loop Until oService.State = "Running"
MsgBox "Automatic Update reset is complete!" & vbCRLF & "The Automatic Update client on " & strComputer & " will begin the update detection process in approximately 10 minutes.", 64, "Automatic Updates
-----------------------------------------------------------
Set WSHShell = WScript.CreateObject("WScript.Shell")
Set WNetwork = Wscript.CreateObject("Wscript.Network")
On Error Resume Next
'Query for target computer
strComputer = InputBox("Please enter the name of the computer you want to reset.", "Reset SUS Client Updates", WNetwork.ComputerName)
If strComputer = "" Then Wscript.Quit
strComputer = Ucase(strComputer)
'Stop the Automatic Updates service
Set oService = GetObject("WinMgmts:{impersonationLevel=impersonate}!//" & strComputer & "/root/cimv2:Win32_Service.Name='wuauserv'")
If Err = 462 Then
MsgBox "Computer " & strComputer & " does not exist.", 16, "Error"
Wscript.Quit
End If
If oService.StartMode = "Disabled" Then
MsgBox "The Automatic Updates service on " & strComputer & " is disabled." & vbCRLF & "No changes have been made.", 16, "Automatic Updates Error"
Wscript.Quit
Else
If oService.StartMode = "Manual" Then
Auto = MsgBox("The Automatic Updates service on " & strComputer & " is set to Manual." & vbCRLF & "Do you want to set it to Automatic?", 36, "Automatic Updates Service")
If Auto = vbYes Then oService.ChangeStartMode("Automatic")
End If
oService.StopService
End If
'Wait until the service stops
Do
Set oService = GetObject("WinMgmts:{impersonationLevel=impersonate}!//" & strComputer & "/root/cimv2:Win32_Service.Name='wuauserv'")
Loop Until oService.State = "Stopped"
'Reset the AUState to detect pending updates
WSHShell.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\AUState", 2, "REG_DWORD"
WshShell.RegWrite "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU\NoAutoUpdate", "0", "REG_DWORD"
'Force Automatic Updates
WSHShell.RegWrite "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU\AUOptions", "4", "REG_DWORD"
WSHShell.RegWrite "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\AUOptions", "4", "REG_DWORD"
WSHShell.RegDelete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\DetectionStartTime"
WSHShell.RegDelete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\NextDetectionTime"
WSHShell.RegDelete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\ScheduledInstallDate"
WSHShell.RegDelete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\ScheduledInstallDay"
WSHShell.RegDelete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\ScheduledInstallTime"
'Delete the LastWaitTimeOut value if it exists
WSHShell.RegDelete "HKLM\Software\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\LastWaitTimeout"
'Start the Automatic Updates service
Set oService = GetObject("WinMgmts:{impersonationLevel=impersonate}!//" & strComputer & "/root/cimv2:Win32_Service.Name='wuauserv'")
oService.StartService
'Wait until the service starts
Do
Set oService = GetObject("WinMgmts:{impersonationLevel=impersonate}!//" & strComputer & "/root/cimv2:Win32_Service.Name='wuauserv'")
Loop Until oService.State = "Running"
MsgBox "Automatic Update reset is complete!" & vbCRLF & "The Automatic Update client on " & strComputer & " will begin the update detection process in approximately 10 minutes.", 64, "Automatic Updates