【问题标题】:How to Detect windows update(or KB update) is installed or not using NSIS?如何使用 NSIS 检测 Windows 更新(或 KB 更新)是否安装?
【发布时间】:2018-03-07 17:19:18
【问题描述】:

要执行我的 windows 应用程序,windows 机器需要一些预安装的 windows 更新(如 KB2999226 - 我需要检查此更新)。我需要使用 NSIS 以静默方式通过我的应用程序安装程序安装此更新。

如何使用 NSIS 检查 windows 是否已安装特定更新。

我试过这个NSIS-Windows_Critical_Updates_Mass_Installer,但它不起作用。它无法检查预安装的更新。

我的 Windows 应用程序将在 Windows 7 SP1 及更高版本和 Windows Server 2012 及更高版本上运行。所以我需要检查所有这些版本的更新。

【问题讨论】:

  • 这基本上是两个问题。检查是否安装了上述更新的官方方法是什么,以及如何在 NSIS 中实现此方法。
  • @Anders :ya.. 实际上我曾尝试使用“bat”文件安装更新,但无法静默安装。我安装更新的 bat 文件代码是: echo off start "" wusa "$temp\WindowsUpdate\KB2937592-x86.msu"。我安装更新的第二个优先事项主要是检查更新是否已经安装。

标签: nsis silent-installer windows-update


【解决方案1】:

为了检查是否使用 NSIS 安装了 KB 更新,我使用了以下代码:

section

clearerrors
nsExec::ExecToStack 'cmd /Q /C "%SYSTEMROOT%\System32\wbem\wmic.exe qfe get hotfixid | %SYSTEMROOT%\System32\findstr.exe "^KB2999226""'
Pop $0 ; return value (it always 0 even if an error occured)
Pop $1 ; command output
detailprint $0
detailprint $1

sectionend

要安装更新(.msu 文件),我使用了以下代码。

section

clearerrors
Strcpy $strInstallPath "$temp\Updates\KB2937592-x86.msu"
Push "$temp\RunMSU.Bat"
Strcpy $0 "$temp\RunMSU.Bat"
FileOpen $0 $0 w #open file
FileSeek $0 0 END #go to end
FileWrite $0 "echo off"
FileWriteByte $0 "13"
FileWriteByte $0 "10"
FileWrite $0 "start $\"$\" wusa $\"$strInstallPath$\""
FileClose $0
Execwait "$temp\RunMSU.bat"

sectionEnd

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-06-14
    • 2019-08-09
    • 2016-05-04
    • 2015-02-25
    • 2010-11-02
    • 2020-04-10
    • 2023-04-10
    相关资源
    最近更新 更多