[英]How do I get NSIS to wait on an msi?
我正在NSIS中安裝程序,正在尋找一種方法來啟動msi安裝程序,並等待該安裝程序完成后再繼續。 我已經以各種方式研究了一切可以做到的事,但是沒有運氣。 無論我嘗試哪種方式,MSI都會啟動,但是NSIS腳本會在MSI安裝程序完成之前立即進行(更具體地,據我所知,MSI會快速完成,但是會啟動它自己的獨立安裝程序EXE,即NSIS腳本不會等待)。
代碼摘錄,包括我嘗試注釋掉的許多不同方法中的一些。
# Include files
!include x64.nsh
!include nsdialogs.nsh
!include LogicLib.nsh
!include MUI2.nsh
!include WinVer.nsh
!include nsDialogs_userData.nsh
!include StrFunc.nsh
!include nsDialogs_createIPaddress.nsh
!include nsProcess.nsh
!include WordFunc.nsh
!include WinMessages.nsh
!include FileFunc.nsh
Function MYSQL_SERVER_INSTALLATION
;Exec 'start /wait "msiexec.exe" /i "$INSTDIR\mysql-installer-community-5.7.13.0.msi"'
ExecWait '"msiexec.exe" /i "$INSTDIR\mysql-installer-community-5.7.13.0.msi"'
;Pop $0
;ExecDos::wait $0
#The mySQL msi opens up MySQLInstaller.exe. That's the real program to wait on.
;ExecWait '"$PROGRAMFILES\MySQL\MySQL Installer for Windows\MySQLInstaller.exe" /s'
MSILoop:
FindProcDLL::FindProc "$INSTDIR\mysql-installer-community-5.7.13.0.msi"
StrCmp $R0 0 0 +2
MessageBox MB_OK "The number is $R0 meaning $INSTDIR\mysql-installer-community-5.7.13.0.msi is not found."
Goto MySQLInstallerLoop
StrCmp $R0 1 0 +2
MessageBox MB_OK "The number is $R0 meaning $INSTDIR\mysql-installer-community-5.7.13.0.msi is found."
Goto MSILoop
MySQLInstallerLoop:
FindProcDLL::FindProc "$PROGRAMFILES\MySQL\MySQL Installer for Windows\MySQLInstaller.exe"
StrCmp $R0 0 0 +2
MessageBox MB_OK "The number is $R0 meaning $PROGRAMFILES\MySQL\MySQL Installer for Windows\MySQLInstaller.exe is not found."
Goto ConfigureDatabase
StrCmp $R0 1 0 +2
MessageBox MB_OK "The number is $R0 meaning $PROGRAMFILES\MySQL\MySQL Installer for Windows\MySQLInstaller.exe is found."
Goto MySQLInstallerLoop
; FindProcDLL::WaitProcStart "$PROGRAMFILES\MySQL\MySQL Installer for Windows\MySQLInstaller.exe" 500
; FindProcDLL::WaitProcEnd "$PROGRAMFILES\MySQL\MySQL Installer for Windows\MySQLInstaller.exe" -1
ConfigureDatabase:
# Configure the MySQL Community
!insertmacro ConfigureMySQLDatabase
!insertmacro CreateMySQLMCSTDatabases
# Delete the MySQL Community installation
SetOutPath "$INSTDIR"
Delete /REBOOTOK "$INSTDIR\mysql-installer-community-${MYSQL_VERSION}.msi"
FunctionEnd
作為參考,我正在Windows 10 64位計算機上進行開發和交付,並且正在使用NSIS v3.01。
Exec 'start /wait ...'
永遠不會起作用,即使將其更改為ExecWait
它也仍然無法起作用,因為start
是Windows NT系統上cmd.exe內部的內部命令。
只是為了ExecWait
, ExecWait
總是等待,但只等待子進程,而不是孫子進程。 可以使用作業對象來等待孫子,但是MSI使用的不是Windows的Windows服務,因此作業對象可能不會在這里為您提供幫助。
任何類型的查找過程插件都無法使用,因為.MSI文件不是PE可執行文件,它只是一個數據庫,也許還有一些CAB壓縮文件。
正確的解決方案是使用ExecWait
但是您必須詢問要切換到MSIExec和/或其安裝程序.EXE的MySQL人員。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.