我正在NSIS的安装程序上工作,我正在寻找一种方法来启动msi安装程序,并在继续之前等待该安装程序完成。我已经研究了我所能做的各种方法,但没有运气。无论我如何尝试,msi都会启动,但在msi安装程序完成之前,NSIS脚本就会继续进行(更具体地说,正如我所了解的,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位机器上开发和交付,我使用的是NSISv3.01。
发布于 2017-08-09 20:00:48
Exec 'start /wait ...'
永远不会工作,即使您将它更改为ExecWait
,它仍然无法工作,因为start
是Windows系统上cmd.exe内部的一个内部命令。
为了澄清问题,ExecWait
总是在等待,但它只是等待子进程,而不是孙子。使用作业对象可以等待孙子,但MSI使用的不是孙辈的Windows,因此作业对象可能不会在这里帮助您。
任何类型的查找进程插件都不能工作,因为一个.MSI文件不是PE可执行文件,它只是一个数据库,或者是一些CAB压缩文件。
正确的解决方案是使用ExecWait
,但您必须要求切换到MSIExec和/或他们的安装程序.EXE的MySQL人员.
https://stackoverflow.com/questions/45599373
复制相似问题