Bize Ulaşın / Contact Us

On-demand install script for Windows Update clients

16 / 12 / 2011 by WSUS Yorum yok / No Comments

You can safely use the VBScript below, from any server console, it immediately downloads and installs all approved patches then reboot if required.

Set fso = CreateObject(“Scripting.FileSystemObject”)
Set objAutomaticUpdates = CreateObject(“Microsoft.Update.AutoUpdate”)

Set objSession = CreateObject(“Microsoft.Update.Session”)
Set objSearcher = objSession.CreateUpdateSearcher()
Set objResults = objSearcher.Search(“IsInstalled=0 and Type=’Software'”)
Set colUpdates = objResults.Updates
Set objUpdatesToDownload = CreateObject(“Microsoft.Update.UpdateColl”)
intUpdateCount = 0

For i = 0 to colUpdates.Count – 1
 intUpdateCount = intUpdateCount + 1
 Set objUpdate = colUpdates.Item(i)

If intUpdateCount = 0 Then
 Set objDownloader = objSession.CreateUpdateDownloader()
 objDownloader.Updates = objUpdatesToDownload

 Set objInstaller = objSession.CreateUpdateInstaller()
 objInstaller.Updates = objUpdatesToDownload
 Set installationResult = objInstaller.Install()
 Set objSysInfo = CreateObject(“Microsoft.Update.SystemInfo”)

 If objSysInfo.RebootRequired Then
  Set objWMIService = GetObject(“winmgmts:{impersonationLevel=impersonate, Shutdown)}!\\localhost\root\cimv2”)
  Set colOperatingSystems = objWMIService.ExecQuery(“Select * from Win32_OperatingSystem”)
  For Each objOperatingSystem in colOperatingSystems
 End If
End If

Source : Best Practices in Architecting and Implementing Windows Server Update Services (WSUS)

Leave a Reply

Your email address will not be published. Required fields are marked *

Kontrol / Control * Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.