如何安装或不使用NSIS检测Windows Update(或KB Update)



要执行我的Windows应用程序,Windows机器需要一些预安装的Windows更新(例如KB2999226-我需要检查此更新)。我需要使用NSIS默默地安装程序安装此更新。

如何检查Windows已经使用NSIS安装了特定的更新。

我尝试过此nsis-windows_critical_updates_mass_installer,但它不起作用。它无法检查预安装的更新。

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

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

section
clearerrors
nsExec::ExecToStack 'cmd /Q /C "%SYSTEMROOT%System32wbemwmic.exe qfe get hotfixid | %SYSTEMROOT%System32findstr.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 "$tempUpdatesKB2937592-x86.msu"
Push "$tempRunMSU.Bat"
Strcpy $0 "$tempRunMSU.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 "$tempRunMSU.bat"
sectionEnd

最新更新