2011-02-17 71 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 
相關問題