如何强制Windows检查更新?
在全新安装Windows–XP或7之后,如何 “强制 "Windows更新?
我不想一周后Windows更新就 "老 "了,那能不能 "一步到位"?有没有什么 "神奇 "的命令可以强制Windows检查更新,如果有,就安装?
在全新安装Windows–XP或7之后,如何 “强制 "Windows更新?
我不想一周后Windows更新就 "老 "了,那能不能 "一步到位"?有没有什么 "神奇 "的命令可以强制Windows检查更新,如果有,就安装?
您可以使用脚本自动检查和安装更新。这将在XP或Windows 7中工作。
有很多脚本可以下载,这里是我的。
' 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
你从命令行运行这个,像这样。
cscript wsusupdate.vbs
我的脚本只是最低限度的功能,但可能仍然有用。还有其他类似的脚本,有很多额外的功能,可以尝试在Google上搜索。
强制重新扫描更新的另一种方法是擦拭干净,通过删除存储在%windir%/Windows/SoftwareDistribution/Download中的所有更新。
NET STOP wuauserv
RD /S /Q %windir%\SoftwareDistribution\Download
NET START wuauserv
然后进入Windows更新,然后 “检查更新"。这可能需要一个小时,因为系统卷上的每个可更新文件都会被检查(后续的 "检查更新 "会很快)。这种方法可以消除错误、拙劣的更新,并产生一个干净的、最新的系统,至少在MS看来是这样。