检查返回码(或其他内容)以确保MSI已正确安装 [英] Check return code (or something else) to ensure MSI has installed correctly
问题描述
我正在使用NSIS安装一些MSI.我正在使用ExecWait "msiexec /passive /liare+ ${SETUP_LOG_FILE} -i $TEMP\MyMsi.msi"
.当MSI与已安装的应用程序具有相同的版本时,它将失败安装(已经安装了该产品的另一个版本"),但是NSIS继续运行,好像没有任何问题. (但是日志文件显示了问题所在.)
I am using NSIS to install some MSIs. I'm using ExecWait "msiexec /passive /liare+ ${SETUP_LOG_FILE} -i $TEMP\MyMsi.msi"
. When the MSI is of the same version as an installed app, it fails the installation ("Another version of this product is already installed"), but NSIS continues on as if nothing is wrong. (But the log file reveals the problem.)
如何检查MSI安装是否失败?如果失败了,停止NSIS安装的正确方法是什么?
How can I check to see if the MSI install failed? If it did fail, what is the correct way to halt the NSIS installation?
推荐答案
从@Wim的答案开始,这是我的解决方案. (我需要安装的应用程序的名称是"Evergreen Programmer",并且还提供了代码来检查CPU是32位还是64位.)我不喜欢Abort
使GUI看起来很像的方式,但是(用户必须单击取消"):
Going off of @Wim's answer, here is my solution. (The name of the app I need to install is "Evergreen Programmer", and there is also code to check if the CPU is 32- or 64-bit.) I don't like the way Abort
makes the GUI look, though (the user has to click Cancel):
!include "x64.nsh"
Function CheckReturnCode
DetailPrint "MSI return code was $0"
${If} $0 != 0
Abort "There was a problem installing the application."
${EndIf}
FunctionEnd
Section "FrameworkAndApp" SecFrameworkApp
SetOutPath "$TEMP"
File /oname=EvergreenProgrammerSetup.msi "${SETUP_FILE}"
File /oname=EvergreenProgrammerSetup64.msi "${SETUP_FILE_64}"
InstallEvergreenProgrammer:
Push "Starting Evergreen Programmer Install Version ${MAJOR_VERSION}.${MINOR_VERSION}.${REVISION}"
Call DebugLog
DetailPrint "Starting Evergreen Programmer Install Version ${MAJOR_VERSION}.${MINOR_VERSION}.${REVISION}"
IfSilent InstallAppWithNoProgressBar
${If} ${RunningX64}
DetailPrint "64-bit detected"
ExecWait "msiexec /passive /liare+ ${SETUP_LOG_FILE} -i $TEMP\EvergreenProgrammerSetup64.msi" $0
${Else}
ExecWait "msiexec /passive /liare+ ${SETUP_LOG_FILE} -i $TEMP\EvergreenProgrammerSetup.msi" $0
${EndIf}
Call CheckReturnCode
SetRebootFlag true
Goto EndInstall
InstallAppWithNoProgressBar:
${If} ${RunningX64}
DetailPrint "64-bit detected"
ExecWait "msiexec /quiet /liare+ ${SETUP_LOG_FILE} -i $TEMP\EvergreenProgrammerSetup64.msi" $0
${Else}
ExecWait "msiexec /quiet /liare+ ${SETUP_LOG_FILE} -i $TEMP\EvergreenProgrammerSetup.msi" $0
${EndIf}
Call CheckReturnCode
SetRebootFlag true
Goto EndInstall
EndInstall:
IfRebootFlag PromptForReboot
Return
PromptForReboot:
IfSilent SkipReboot
MessageBox MB_OK "The application will not function correctly without a reboot or log off."
SkipReboot:
SectionEnd
这篇关于检查返回码(或其他内容)以确保MSI已正确安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!