如何在Windows的添加/删除程序列表中添加程序以便列出它(所以我可以点击它来卸载)?
答案 0 :(得分:11)
卸载注册存储在注册表中,注册表中应保存它取决于安装程序是为所有用户还是单个用户安装程序(IE是您的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具有更完整的列表...
答案 1 :(得分:3)
使用示例:
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