简体   繁体   中英

How to create registry key in HKLM using Inno Setup without requiring Administrator permissions

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 (ie 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!

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM