我重用在安装过程中写入的UninstallString
或QuietUninstallString
注册表项,以便稍后确定卸载程序命令。
一对夫妇在顶部定义:
!define PROJECT_REG_UNINSTALL_KEY "SoftwareMicrosoftWindowsCurrentVersionUninstall${PROJECT_NAME}"
!define PROJECT_UNINSTALL_EXE "uninstall.exe"
在安装程序部分
中:
WriteRegStr HKLM "${PROJECT_REG_UNINSTALL_KEY}" "UninstallString" "$INSTDIR${PROJECT_UNINSTALL_EXE}" _?=$INSTDIR
WriteRegStr HKLM "${PROJECT_REG_UNINSTALL_KEY}" "QuietUninstallString" "$INSTDIR${PROJECT_UNINSTALL_EXE}" /S _?=$INSTDIR
然后在.onit
中获取注册表项值(如果你的应用程序已经以这种方式安装,则会存在)并运行它:
${If} ${Silent}
ReadRegStr $R0 HKLM "${PROJECT_REG_UNINSTALL_KEY}" "QuietUninstallString"
${Else}
ReadRegStr $R0 HKLM "${PROJECT_REG_UNINSTALL_KEY}" "UninstallString"
${EndIf}
ExecWait "$R0"