2011-02-17 6 views

risposta

11

La registrazione di disinstallazione è memorizzato nel Registro di sistema, in cui nel Registro di sistema si dovrebbe salvare dipende se il vostro programma di installazione installa il programma per tutti gli utenti o un singolo utente (cioè il vostro RequestExecutionLevel impostazione):

  • user = HKCU
  • admin = HKLM
  • più alto = SHCTX (Questo significa che è necessario utilizzare SetShellVarC ontext correttamente e ripristinarlo correttamente nel programma di disinstallazione)

Sono necessari solo due valori: DisplayName e 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 

Ci sono diversi valori opzionali è possibile impostare, MSDN in realtà non fornisce un elenco di valori documentati, ma la NSIS Wiki has a decent list e this page ha una lista ancora più completa ...

+0

N.B. Esiste una posizione separata per le installazioni a 32 bit su una macchina a 64 bit: https://superuser.com/a/293896/41494 – icc97

+0

@ icc97 Ciò dipende molto. Un programma di installazione a 32 bit scriverà nella parte a 32 bit del registro su Windows a 64 bit. Ma per visualizzare la chiave in Regedit, allora sì, è necessario visualizzare la chiave WoW64 se si esegue Regedit.exe a 64 bit. – Anders

3

Esempio di utilizzo:

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