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?
Asked
Active
Viewed 5,544 times
2 Answers
15
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...

Anders
- 97,548
- 12
- 110
- 164
-
N.B. There's a separate location for 32-bit installations on a 64-bit machine: https://superuser.com/a/293896/41494 – icc97 Feb 23 '18 at 16:13
-
@icc97 That really depends. A 32-bit installer will write to the 32-bit part of the registry on 64-bit Windows. But to view the key in Regedit, then yes, you must view the WoW64 key if you run the 64-bit Regedit.exe. – Anders Feb 23 '18 at 17:23
4
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

Creshal
- 493
- 1
- 4
- 15