如何在 Windows 添加/删除程序列表中添加程序

发布于 2024-10-18 00:35:16 字数 54 浏览 2 评论 0原文

如何添加该程序以便将其列在 Windows 的添加/删除程序列表中(以便我可以单击它来卸载)?

How do i add the program so that it is listed (so i can click on it to uninstall) in windows's add/remove program list?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

无法回应 2024-10-25 00:35:16

卸载注册存储在注册表中,您应该将其保存在注册表中的位置取决于您的安装程序是为所有用户还是单个用户安装程序(IE您的RequestExecutionLevel设置):

  • 用户= HKCU
  • 管理员= HKLM
  • 最高= SHCTX(这意味着您必须正确使用 SetShellVarContext 并在卸载程序中正确恢复它)

只需要两个值: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 有一个不错的列表此页面有一个更完整的列表。 ..

The uninstall registration is stored in the registry, where in the registry you should save it depends on if your installer installs the program for all users or a single user (IE your RequestExecutionLevel setting):

  • user = HKCU
  • admin = HKLM
  • highest = SHCTX (This means you must use SetShellVarContext correctly and also restore it correctly in the uninstaller)

There are only two values that are required: DisplayName and 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

There are several optional values you can set, MSDN does not really provide a list of documented values but the NSIS Wiki has a decent list and this page has a even more complete list...

十秒萌定你 2024-10-25 00:35:16

用法示例:

 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

Example usage:

 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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文