Search code examples
nsis

How do i add the program in windows add/remove program list


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?


Solution

  • 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...