简体   繁体   English

如何使用NSIS检测Windows更新(或KB更新)是否已安装?

[英]How to Detect windows update(or KB update) is installed or not using NSIS?

To execute my windows application, windows machine needs some pre-installed windows update(Like KB2999226 - I need to check this update). 要执行我的Windows应用程序,Windows机器需要一些预安装的Windows更新(例如KB2999226-我需要检查此更新)。 I need to install this updates with my application installer silently using NSIS. 我需要使用NSIS通过应用程序安装程序静默安装此更新。

How to check windows has already installed particular update using NSIS. 如何检查Windows已使用NSIS安装了特定更新。

I have tried this NSIS-Windows_Critical_Updates_Mass_Installer but its not working. 我已经尝试过此NSIS-Windows_Critical_Updates_Mass_Installer,但无法正常工作。 It's not able to check pre-installed update. 它无法检查预装的更新。

My windows application will run on Windows 7 SP1 and later version and windows server 2012 and later version. 我的Windows应用程序将在Windows 7 SP1和更高版本以及Windows Server 2012和更高版本上运行。 So i need to check updates in all this versions. 所以我需要检查所有这些版本中的更新。

To check whether KB update is installed or not using NSIS I have used below code: 要使用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

To install update(.msu file) I have used below code. 要安装update(.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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM