1

I am developing desktop application using C# and creating setup using Inno setup compiler.

Let me explain application functionality,

  1. I have created application Setup using Inno Setup all user (i.e. application can install in admin/non admin PC).

    //all user
    PrivilegesRequired=lowest
    
  2. While installing application, I want to create registry key in HKLM. For this I have added registry key in Inno Setup script as below

    [Registry]
    Root: HKLM; Subkey: "SOFTWARE\Wow6432Node\TestKey"; Permissions: users-modify; \
        Flags: uninsdeletekey createvalueifdoesntexist; ValueType: string; \
        ValueName: "SOAPAddress"; ValueData: "ABC"
    
  3. While installing application registry key not created its throws below exception

    ---------------------------
    Error
    ---------------------------
    Error creating registry key:
    
    HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\TestKey
    
    RegCreateKeyEx failed; code 5.
    
    Access is denied.
    
    Click Retry to try again, Ignore to proceed anyway, or Abort to cancel installation.
    

Please help me, How can I create registry key in HKLM using Inno Setup compiler.

I had checked in VS2010 its create registry key but setup can't run non-admin PC.

Thanks in advance!

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Kishor T
  • 300
  • 1
  • 4
  • 15

1 Answers1

8

You need Administrator privileges to write to HKLM. So you cannot use the PrivilegesRequired=lowest.

And creating an user-writable key in HKLM is a bad practice.

You cannot have an installer that can be run by a non-admin user, yet be able to write to HKLM. That's a basic principle of Windows security.


It's not really clear what you mean by "application can install in Admin/non admin PC", but maybe you are actually looking for this:
Make Inno Setup installer request privileges elevation only when needed.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992