Search code examples
permissionsregistrynsisuninstallationuser-permissions

Possible to write NSIS uninstall information without administrative privileges?


Recently I change my NSIS-based installer from installing into the "program files" folder to install into the local user folder, to enable normal user accounts to install without administrative UAC elevation (similar to how SkyDrive or Google Chrome does it).

To enable uninstall the installer used something like:

; Shortcut for the key.
!define REG_U "Software\Microsoft\Windows\CurrentVersion\Uninstall\ZetaUploader"

; Write uninstall strings.
WriteRegStr HKLM "${REG_U}" "DisplayName" "Zeta Uploader ${VERSION}"
WriteRegStr HKLM "${REG_U}" "DisplayVersion" "${VERSION}"
WriteRegStr HKLM "${REG_U}" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteRegStr HKLM "${REG_U}" "Publisher" "Zeta Software GmbH"
WriteRegStr HKLM "${REG_U}" "URLInfoAbout" "https://www.zeta-uploader.com"

This worked well when running with administrative permission but fails (silently) when running with user permissions.

My question therefore is:

Is there a possibility to add to the central uninstall control panel window without administrative permissions?

I tried to search for a HKCU key similar to the HKLM keys for uninstall but found none. In addition I'm aware that I could write a start menu entry to uninstall, but I do not want my to make it too easy for my users to remove the application.

Update 1 / solution:

Based on Anders answer, I found this blog posting with this example NSI script that explains it the same way.

So the final solution looks like:

; Shortcut for the key.
!define REG_U "Software\Microsoft\Windows\CurrentVersion\Uninstall\ZetaUploader"

; Write uninstall strings.
WriteRegStr HKCU "${REG_U}" "DisplayName" "Zeta Uploader ${VERSION}"
WriteRegStr HKCU "${REG_U}" "DisplayVersion" "${VERSION}"
WriteRegStr HKCU "${REG_U}" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteRegStr HKCU "${REG_U}" "Publisher" "Zeta Software GmbH"
WriteRegStr HKCU "${REG_U}" "URLInfoAbout" "http://www.zeta-uploader.com"

(Please note that HKLM from the first code snippet was replaced with HKCU).


Solution

  • You were on the right track, HKCU with the same sub path as HKLM is the correct location.

    It does not exist by default but should work on any recent version of Windows (Does not work on Win9x, not sure about NT4 and 2000)