VBScript - Set Windows Update via Intranet Server

Environment
  • Microsoft Windows XP
Version
  • 2009-NOV-26
Codes
'Ref: http://technet.microsoft.com/en-us/library/cc720464.aspx

Dim oShell
Dim elevateNonAdmins
Dim auOptions
Dim autoInstallMinorUpdates
Dim noAutoUpdate
Dim detectionFrequency
Dim detectionFrequencyEnabled
Dim noAutoRebootWithLoggedOnUsers
Dim useWUServer
Dim rescheduleWaitTime
Dim scheduledInstallDay
Dim scheduledInstallTime
Dim wuServer
Dim wuStatusServer

Set oShell = WScript.CreateObject("WScript.Shell")

'wuServer and WUStatus Server must be the same
wuServer = "http://WSUSServer"
wuStatusServer = "http://WSUSServer"

' 1 = Allow non administrators to apporove or deny updates
' 0 = Only administrators to approve or deny updates
elevateNonAdmins = 0

' 2 = Notify before download
' 3 = Automatically download and notify of installation
' 4 = Automatic download and scheduled installation. (Only valid if values exist for scheduledInstallDay and scheduledInstallTime.)
' 5 = Automatic Updates is required, but end users can configure it
auOptions = 4

' 0 = Treat minor updates like other updates.
' 1 = Silently install minor updates.
autoInstallMinorUpdates = 1

' 0 = Enable Automatic Updates.
' 1 = Disable Automatic Updates.
noAutoUpdate = 0

' In hours (0-22)
detectionFrequency = 22

' 0 = Disable custom detectionFrequency (use default value of 22 hours)
' 1 = Enable detectionFrequency.
detectionFrequencyEnabled = 1

' 0 = Automatic Updates notifies user that the computer will restart in 5 minutes.
' 1 = Logged-on user gets to choose whether or not to restart his or her computer.
noAutoRebootWithLoggedOnUsers = 1

' The wuServer value is not respected unless this key is set
useWUServer = 1

' 0 = Disable reboot warning time out. If this, would use the default one - 5mins
' 1 = Enable reboot warning time out
rebootWarningTimeoutEnabled = 1

' Reboot warning timeout from 1 to 30 minutes
rebootWarningTimeout = 30

' 0 = Disable reboot relaunch time out. If this, would use the default one - 10mins
' 1 = Enable reboot relaunch time out
rebootRelaunchTimeoutEnabled = 1

' Time between prompting again for a scheduled restart from 1 to 1440 mins
rebootRelaunchTimeout = 480

' 0 = Disable RescheduleWaitTime
' 1 = Enable RescheduleWaitTime
rescheduleWaitTimeEnabled = 1

' The waiting of Automatic Updates is at startup, which is for applying missed scheduled installation of other updates
' Time in minutes (1 - 60)
rescheduleWaitTime = 60

' 0 = Every day.
' 1 through 7 = The days of the week from Sunday (1) to Saturday (7)
scheduledInstallDay = 0

' In hours (0-23)
scheduledInstallTime = 12

' wuServer
oShell.RegWrite"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\WUServer", wuServer, "REG_SZ"

' wuStatusServer
oShell.RegWrite"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\WUStatusServer", wuStatusServer, "REG_SZ"

' elevateNonAdmins
oShell.RegWrite"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\ElevateNonAdmins", elevateNonAdmins, "REG_DWORD"

' auOptions
oShell.RegWrite"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU\AUOptions", auOptions, "REG_DWORD"

' autoInstallMinorUpdates
oShell.RegWrite"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU\AutoInstallMinorUpdates", autoInstallMinorUpdates, "REG_DWORD"

' noAutoUpdate
oShell.RegWrite"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU\NoAutoUpdate", noAutoUpdate, "REG_DWORD"

' detectionFrequency
oShell.RegWrite"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU\DetectionFrequency", detectionFrequency, "REG_DWORD"

' detectionFrequencyEnabled
oShell.RegWrite"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU\DetectionFrequencyEnabled", detectionFrequencyEnabled, "REG_DWORD"

' noAutoRebootWithLoggedOnUsers
oShell.RegWrite"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU\NoAutoRebootWithLoggedOnUsers", noAutoRebootWithLoggedOnUsers, "REG_DWORD"

' useWUServer
oShell.RegWrite"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU\UseWUServer", useWUServer, "REG_DWORD"

' rebootWarningTimeoutEnabled
oShell.RegWrite"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU\RebootWarningTimeoutEnabled", rebootWarningTimeoutEnabled, "REG_DWORD"

' rebootWarningTimeout
oShell.RegWrite"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU\RebootWarningTimeout", rebootWarningTimeout, "REG_DWORD"

' rebootRelaunchTimeoutEnabled
oShell.RegWrite"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU\RebootRelaunchTimeoutEnabled", rebootRelaunchTimeoutEnabled, "REG_DWORD"

' rebootRelaunchTimeout
oShell.RegWrite"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU\RebootRelaunchTimeout", rebootRelaunchTimeout, "REG_DWORD"

' rescheduleWaitTimeEnabled
oShell.RegWrite"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU\RescheduleWaitTimeEnabled", rescheduleWaitTimeEnabled, "REG_DWORD"

' rescheduleWaitTime
oShell.RegWrite"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU\RescheduleWaitTime", rescheduleWaitTime, "REG_DWORD"

' scheduledInstallDay
oShell.RegWrite"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU\ScheduledInstallDay", scheduledInstallDay, "REG_DWORD"

' scheduledInstallTime
oShell.RegWrite"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU\ScheduledInstallTime", scheduledInstallTime, "REG_DWORD"

'Restart WSUS service
oShell.Run "%windir%\system32\wuauclt.exe /resetauthorization /detectnow"
Reference
  • Configure Clients in a Non–Active Directory Environment (Registry): http://technet.microsoft.com/en-us/library/cc720464.aspx
  • Group Policy: http://technet.microsoft.com/en-us/library/cc708574.aspx