1

我有一个安装程序,它强制在安装新版本之前卸载以前的版本。

但是,当最初的问题被问到时,它会这样做。但卸载对话框没有。

MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
  "${PRODUCT_NAME} is already installed. $\n$\nIf you have software older than 3.0,     please manually uninstall it with Windows before procedeing. $\n$\nClick `OK` to remove the \
  previous version or `Cancel` to cancel this upgrade." \
  IDOK uninst IDCANCEL giveup

; I am giving up
giveup:
Abort

;  Run the uninstaller
uninst:
 ClearErrors
 ExecWait '$R0 _?=$INSTDIR' ;Do not copy the uninstaller to a temp file
 IfErrors no_remove_uninstaller
 no_remove_uninstaller:
 install:
 ; ..... snip

那么这里

Function un.onInit
   MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to     completely remove $(^Name) and all of its components?" IDYES NoAbort
  Abort
  NoAbort:
FunctionEnd

因此,当它是独立卸载时似乎很好,但是当它开始卸载时,如果用户说“否/取消”,安装程序仍然会在他们说“不”时继续。我想不出为什么。作为不良副作用,开始菜单上的程序文件图标是孤立的,uninst.exe 是孤立的。但是,如果您“手动”运行卸载程序,它似乎没问题。除了试图让这件事发挥作用之外,我没有改变任何逻辑。

谢谢。

4

1 回答 1

2

重要的是在 ExecWait 中引用路径,然后检查退出代码:

Function .onInit
StrCpy $R0 "c:\old install" ; TODO: Somehow find the old install (in the registry? InstallDirRegKey?) and put its path in $R0
IfFileExists "$R0\*.*" 0 noOldInstall
    MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "${PRODUCT_NAME} is already installed. blahblah..." IDOK uninstOld
    Abort
    uninstOld:
    ExecWait '"$R0\uninstaller.exe" _?=$R0' $R1
    ; Exit codes are documented in Appendix D in the help file.
    StrCmp $R1 0 noOldInstall ; Success? If so we are done...
    Abort ; Uninstaller was canceled or failed, we cannot continue
noOldInstall:
FunctionEnd
于 2013-04-11T18:51:04.927 回答