【发布时间】:2021-05-19 14:56:14
【问题描述】:
为了签署安装程序和卸载程序,我创建了一个单独的卸载程序脚本,如下所示:https://nsis-dev.github.io/NSIS-Forums/html/t-245688.html。因此,卸载程序脚本没有使用WriteUninstaller的方式来创建卸载程序。
请注意,我使用SelfDel插件删除卸载程序,成功运行;但是,即使我使用/RMDIR 选项,它实际上并没有删除应用程序安装目录:
Function .onInstSuccess
;SelfDel::Del /REBOOT
;SelfDel::Del /SHUTDOWN
SelfDel::Del /RMDIR
SelfDel::Del
SetAutoClose true
FunctionEnd
这是完整的脚本供您参考。
!define APP_COPYRIGHT "MyApp © MyCompany 2021"
!define COMPANY_NAME "MyCompany"
!define LANG_ENGLSH "English"
!define PRODUCT_NAME "MyApp"
!define PRODUCT_VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}.${BUILD_VERSION}"
!define SETUP_NAME "uninstaller.exe"
# define the name of the installer
OutFile ${SETUP_NAME}
Icon "favicon.ico"
!define MUI_ICON "favicon.ico"
# define the directory to install to
InstallDir "$PROGRAMFILES64\${PRODUCT_NAME}\"
# default section
Section
# define the output path for this file
SetOutPath $INSTDIR
# now delete installed files and registry keys for MyApp
ReadRegStr $0 HKCU "SOFTWARE\${PRODUCT_NAME}" "InstallLocation"
DeleteRegKey HKCU "SOFTWARE\${PRODUCT_NAME}"
Delete $0\config.dat
Delete $0\MyApp.exe
Delete $0\ReleaseNotes.txt
Delete $0\MyApp_LandingPage_114.bmp
Delete $0\MyAppLicense.txt
Delete "$SMPROGRAMS\MyApp.lnk"
DeleteRegKey HKCU "SOFTWARE\${PRODUCT_NAME}"
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
DeleteRegKey /ifempty HKCU "Software\Modern UI Test"
SectionEnd
Function .onInstSuccess
;SelfDel::Del /REBOOT
;SelfDel::Del /SHUTDOWN
SelfDel::Del /RMDIR
SelfDel::Del
SetAutoClose true
FunctionEnd
有人对如何让它删除应用程序目录有任何建议吗? TIA。
【问题讨论】:
-
为什么要调用两次插件?
-
我建议您返回使用 !system 签名的生成签名卸载程序的原始方法。
-
这是理想的解决方案,但正如我在这里提到的stackoverflow.com/questions/66108923/…,当我尝试将签名保持在一个部分之外和部分内部时,我都会遇到错误。你有什么建议吗?
-
这里的例子只是部分脚本:nsis.sourceforge.io/Signing_an_Uninstaller。您是否碰巧知道某处的完整示例?该示例的顶部是函数的一部分吗?如果是这样,那我该如何调用该函数?
-
该 wiki 页面上的脚本不是部分的,它按原样工作(在更改 SIGNCODE 参数之后)。
标签: nsis