如何强制 Windows 检查更新?

如何强制 Windows 检查更新?

全新安装 Windows(XP 或 7)后,如何“强制”Windows 更新?

我不想在一周后收到“旧”的 Windows 更新,那么可以“一步到位”地完成吗?是否有任何“神奇”的命令可以强制 Windows 检查更新,如果有,则安装它们?

答案1

您可以使用脚本自动检查并安装更新。这适用于 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 搜索。

答案2

除了通常使用 Windows Update 的方式之外,您还可以通过命令行强制检查。

打开管理员命令提示符并运行:

C:\> %windir%\system32\wuauclt.exe /detectnow

Wuauclt.exe 是 Windows Update 的自动更新客户端,用于从 Microsoft Update 检查可用的更新(针对 MS Windows 平台的各个版本)。

这不会强制安装。

答案3

要检查更新,请转到控制面板、安全、Windows 更新,然后单击“检查更新”。

在此处输入图片描述

答案4

我正在使用一个名为wuinstall用于更新全新的 Windows 安装。通过它,您可以自动执行整个更新过程,包括自动重启。我认为这是在无需用户参与的情况下让全新 Windows 保持更新的最快方法之一。

相关内容