Search code examples
c++windowsregistryuninstallation

Cannot uninstall my tool after adding entry to the 'Uninstall' registry key


I'm developing a simple win32 tool. I'd the tool to be easily uninstalled by the user so I've added a subkey to:

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall

called MyTool and added all the necessary keys such as: DisplayName,UninstallString,DisplayVersion,DisplayIcon

So far so good. I can see that during the install process of my tool, the new subkey was added and everything is as expected.

Problem

When I come to uninstall my tool and press uninstall I get the following error:

You do not have sufficient access to uninstall MyTool. Please contact your system administrator

Notes

My process is 32 bit. However, Wow6432Node related topic is irrelevant since I've encounter this issue both in 32 & 64 bit systems.

Question

Did I do something wrong with the way I've added the registry subkey?


Solution

  • This is the kind of time-wasting bugs that are so stupid.

    The issue was, believe it or not, the path separator used in key's value: UninstallString.

    Generating error

    "C:/Program Files (x86)/MyTool/my_tool.exe" /uninstall"
    

    Working

    "C:\Program Files (x86)\MyTool\my_tool.exe" /uninstall
    

    Regardless of whether or not it is my fault as a developer, why would windows error out in this case?