How do I force Windows to check for updates?
After a fresh Windows install – XP or 7 – how can I "force" Windows updates?
I don't want to have "old" Windows updates after a week, so could it be done in "one step"? Are there any "magical" commands that force Windows to check for updates, and if there are any, install them?
Solution 1:
You can check for and install updates automatically using a script. This will work in either XP or Windows 7.
There are a number of scripts available for download, here is mine:
' Written in 2007 by Harry Johnston, University of Waikato, New Zealand.
' This code has been placed in the public domain. It may be freely
' used, modified, and distributed. However it is provided with no
' warranty, either express or implied.
'
' Exit Codes:
' 0 = scripting failure
' 1 = error obtaining or installing updates
' 2 = installation successful, no further updates to install
' 3 = reboot needed; rerun script after reboot
'
' Note that exit code 0 has to indicate failure because that is what
' is returned if a scripting error is raised.
'
Set updateSession = CreateObject("Microsoft.Update.Session")
Set updateSearcher = updateSession.CreateUpdateSearcher()
Set updateDownloader = updateSession.CreateUpdateDownloader()
Set updateInstaller = updateSession.CreateUpdateInstaller()
Do
WScript.Echo
WScript.Echo "Searching for approved updates ..."
WScript.Echo
Set updateSearch = updateSearcher.Search("IsInstalled=0")
If updateSearch.ResultCode <> 2 Then
WScript.Echo "Search failed with result code", updateSearch.ResultCode
WScript.Quit 1
End If
If updateSearch.Updates.Count = 0 Then
WScript.Echo "There are no updates to install."
WScript.Quit 2
End If
Set updateList = updateSearch.Updates
For I = 0 to updateSearch.Updates.Count - 1
Set update = updateList.Item(I)
WScript.Echo "Update found:", update.Title
Next
WScript.Echo
updateDownloader.Updates = updateList
updateDownloader.Priority = 3
Set downloadResult = updateDownloader.Download()
If downloadResult.ResultCode <> 2 Then
WScript.Echo "Download failed with result code", downloadResult.ResultCode
WScript.Echo
WScript.Quit 1
End If
WScript.Echo "Download complete. Installing updates ..."
WScript.Echo
updateInstaller.Updates = updateList
Set installationResult = updateInstaller.Install()
If installationResult.ResultCode <> 2 Then
WScript.Echo "Installation failed with result code", installationResult.ResultCode
For I = 0 to updateList.Count - 1
Set updateInstallationResult = installationResult.GetUpdateResult(I)
WScript.Echo "Result for " & updateList.Item(I).Title & " is " & installationResult.GetUpdateResult(I).ResultCode
Next
WScript.Quit 1
End If
If installationResult.RebootRequired Then
WScript.Echo "The system must be rebooted to complete installation."
WScript.Quit 3
End If
WScript.Echo "Installation complete."
Loop
You run this from the command line like this:
cscript wsusupdate.vbs
My script is only minimally functional but may still be useful. There are other such scripts available with many additional features, try a Google search.
Solution 2:
Beyond the usual way of using Windows Update, you can force a check from a command-line.
Open an administrator command prompt and run:
C:\> %windir%\system32\wuauclt.exe /detectnow
Wuauclt.exe is the AutoUpdate Client of Windows Update and is used to check for available updates (for the various versions of the MS Windows platform) from Microsoft Update.
This won't force an install.
Solution 3:
TO check for updates, go to Control Panel, Security, Windows Update, then click "Check for updates."
Solution 4:
Another way to force a true rescan for updates is to wipe the slate clean, by deleting all updates stored in %windir%\Windows\SoftwareDistribution\Download:
NET STOP wuauserv
RD /S /Q %windir%\SoftwareDistribution\Download
NET START wuauserv
Then go to Windows Update, and "Check for updates". It may take an hour, because every updateable file on your system volume is checked (subsequent "Checks for updates" will be fast). This approach eliminates errors, botched updates, and yields a clean, up-to-date system, at least insofar as MS sees it.