簡體   English   中英

如何使用NSIS檢測Windows更新(或KB更新)是否已安裝?

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

要執行我的Windows應用程序,Windows機器需要一些預安裝的Windows更新(例如KB2999226-我需要檢查此更新)。 我需要使用NSIS通過應用程序安裝程序靜默安裝此更新。

如何檢查Windows已使用NSIS安裝了特定更新。

我已經嘗試過此NSIS-Windows_Critical_Updates_Mass_Installer,但無法正常工作。 它無法檢查預裝的更新。

我的Windows應用程序將在Windows 7 SP1和更高版本以及Windows Server 2012和更高版本上運行。 所以我需要檢查所有這些版本中的更新。

要使用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

要安裝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