如果 ExecWait 命令获得特定的 return 代码,NSIS 回滚安装程序

NSIS roll-back installer if ExecWait command gets a specific return code

我目前正在使用以下脚本与我的应用程序一起安装驱动程序:

!macro customInstall
  ExecWait '"$INSTDIR\resources\DPInst.exe" /sw'
!macroend

但是,如果 DPInst returns >= 0x80010000,这意味着一个或多个驱动程序安装失败,因此我需要回滚安装并退出。知道我该怎么做吗?

ExecWait 可以在第二个参数中存储进程退出代码。您无能为力将其回滚,最好在安装阶段的早期进行:

!include LogicLib.nsh
Section
SetOutPath "$instdir\resources"
File "whatever\DPInst.exe"
ExecWait '"$INSTDIR\resources\DPInst.exe" /sw' [=10=]
${If} [=10=] U>= 0x80010000
  Delete "$INSTDIR\resources\DPInst.exe"
  RMDir $instdir\resources
  RMDir $instdir
  MessageBox mb_iconstop "Error blah blah"
  Abort
${EndIf}
SectionEnd