【发布时间】:2016-06-30 18:51:04
【问题描述】:
在我的 .nsi 文件中,un.onInit 函数中有以下逻辑:
Function un.onInit
MessageBox MB_YESNO "This will uninstall. Continue?" IDYES checkRunning
checkRunning:
FindProcDLL::FindProc "app.exe"
IntCmp $R0 1 0 notRunning
MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION "${PRODUCT} is running, please close it so the installation can proceed." /SD IDCANCEL IDRETRY checkRunning
Abort
notRunning:
!insertmacro Init "uninstaller"
FunctionEnd
但是,messageBox(和进程正在运行的消息)从未显示。所以我浏览了很多文档,显然运行静默模式会阻止调用此方法,因此我将 SilentInstall normal 和 SilentUnInstall normal 添加到 .nsi 文件中。但是,这也不起作用。
我尝试通过手动转到 uninstall.exe 并运行安装程序来调用卸载程序,该安装程序会检查是否已安装版本以及是否有调用:
uninst:
ClearErrors
ExecWait '$R0 _?=$INSTDIR' ;Do not copy the uninstaller to a temp file
ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT}" "UninstallString"
StrCmp $R0 "" done
Abort
然而,这两个调用都不会触发到“正常”模式。那么如何才能调用我的 un.onInit 函数呢?
编辑:
有人要求提供整个文件,here it is。我只复制了相关部分,但如果需要更多内容,请随时查看。请注意,整个文件已经很旧了,我只是在更新它。
【问题讨论】:
-
你能把整个 .nsi 文件贴在这里吗?调用顺序有时会影响“本机”nsi 方法。另外,“nsProcess.nsh”是我用来检查正在运行的应用程序的;我并不是说这是这里的问题,但我之前没有看到
FindProcDLL用于此... -
@Killercam 检查编辑
-
我很好奇使用
un.onGUIInit时行为是否会发生变化 -
@idleberg 我刚刚尝试过,不幸的是它也没有触发。尽管此功能不用于中止(afaik),但它是一个很好的建议。
标签: nsis uninstallation uninstallstring