2011-02-17 35 views

回答

11

卸载注册存储在注册表中,在注册表中的你应该保存它取决于如果你的安装程序安装为所有用户或单个用户的程序(即你的RequestExecutionLevel设置):

  • 用户= HKCU
  • 管理= HKLM
  • 最高= SHCTX(这意味着你必须使用SetShellVarC ontext正确,并在卸载程序中正确还原)

只有两个值是必需的: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有一个更完整的列表...

+0

注:在64位机器上有32位安装的单独位置:https://superuser.com/a/293896/41494 – icc97 2018-02-23 16:13:24

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 
相关问题