Search code examples
nsis

How can i get path of the installed program from the registry in nsis?


How can i get path of the installed program from the registry in nsis? i am reading registry by readregistry command and assigned to a variable.actually i want to locate my uninstall.exe location.


Solution

  • If you use the InstallDirRegKey instruction, you can specify a registry key where the $INSTDIR directory will be saved for future usage. That key is automatically read the next time the installer starts.

    You can use that to locate the uninstall.exe

    You can also write several keys when installing to configure the windows "add / remove programs", then the unistaller can be located by the UninstallString registry value:

    !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\my_application"
    WriteRegStr HKLM "${PRODUCT_UNINST_KEY}"  "DisplayName" "my_application Uninstaller"
    WriteRegStr HKLM "${PRODUCT_UNINST_KEY}"  "DisplayIcon" "$INSTDIR\my_application.exe,0"
    WriteRegStr HKLM "${PRODUCT_UNINST_KEY}"  "Publisher" "My company"
    WriteRegStr HKLM "${PRODUCT_UNINST_KEY}"  "HelpTelephone" "555-123456"
    
    WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "UninstallString" '"$INSTDIR\uninstall.exe"'