【问题标题】:How do i add the program in windows add/remove program list如何在 Windows 添加/删除程序列表中添加程序
【发布时间】:2011-02-17 11:25:57
【问题描述】:

如何添加程序以便在 Windows 的添加/删除程序列表中列出(以便我可以单击它进行卸载)?

【问题讨论】:

    标签: nsis


    【解决方案1】:

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

    • 用户 = HKCU
    • admin = HKLM
    • highest = 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 has a decent listthis page 有一个更完整的列表...

    【讨论】:

    • 注: 64 位机器上的 32 位安装有一个单独的位置:superuser.com/a/293896/41494
    • @icc97 这真的取决于。 32 位安装程序将写入 64 位 Windows 上注册表的 32 位部分。但是要在 Regedit 中查看密钥,是的,如果您运行 64 位 Regedit.exe,则必须查看 WoW64 密钥。
    【解决方案2】:

    示例用法:

     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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多