【发布时间】:2011-02-17 11:25:57
【问题描述】:
如何添加程序以便在 Windows 的添加/删除程序列表中列出(以便我可以单击它进行卸载)?
【问题讨论】:
标签: nsis
如何添加程序以便在 Windows 的添加/删除程序列表中列出(以便我可以单击它进行卸载)?
【问题讨论】:
标签: nsis
卸载注册存储在注册表中,您应该将其保存在注册表的哪个位置取决于您的安装程序是为所有用户还是单个用户安装程序(即您的 RequestExecutionLevel 设置):
只有两个值是必需的:DisplayName 和 UninstallString。
!define REGUNINSTKEY "MyApplication" ;Using a GUID here is not a bad idea
!define REGHKEY HKLM ;Assuming RequestExecutionLevel admin AKA all user/machine install
!define REGPATH_WINUNINST "Software\Microsoft\Windows\CurrentVersion\Uninstall"
Section
WriteRegStr ${REGHKEY} "${REGPATH_WINUNINST}\${REGUNINSTKEY}" "DisplayName" "My application"
WriteRegStr ${REGHKEY} "${REGPATH_WINUNINST}\${REGUNINSTKEY}" "UninstallString" '"$INSTDIR\uninstaller.exe"'
SectionEnd
您可以设置几个可选值,MSDN 并没有真正提供记录值的列表,但 NSIS Wiki has a decent list 和 this page 有一个更完整的列表...
【讨论】:
示例用法:
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\<Name>" \
"DisplayName" "<Name>" ;The Name shown in the dialog
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\<Name>" \
"UninstallString" "$INSTDIR\<Path to uninstaller>"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\<Name>" \
"InstallLocation" "$INSTDIR"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\<Name>" \
"Publisher" "<Your Name>"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\<Name>" \
"HelpLink" "<URL>"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\<Name>" \
"DisplayVersion" "<Version>"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\<Name>" \
"NoModify" 1 ; The installers does not offer a possibility to modify the installation
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\<Name>" \
"NoRepair" 1 ; The installers does not offer a possibility to repair the installation
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\<Name>" \
"ParentDisplayName" "<Parent>" ;
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\<Name>" \
"ParentKeyName" "<ParentKey>" ; The last two reg keys allow the mod to be shown as an update to another software. Leave them out if you don't like this behaviour
【讨论】: