简体   繁体   中英

How to allow non-admin user to write to registry key HKEY_LOCAL_MACHINE\SOFTWARE\SWname\Licenses

I have a software deployed using Windows Installer.

On Windows XP, When I use non-admin user to install the software package, it asks for administrator's right which is correct. Then I click run as administrator and wait for the installation finish.

Then if I (non-admin user) want to write to registry key "HKEY_LOCAL_MACHINE\\SOFTWARE\\SWname\\Licenses", the software throws an exception. The access is denied.

I use follows in the source code :

RegistryKey rk= Registry.LocalMachine.CreateSubKey("SOFTWARE\\"+swName+"\\Licenses", RegistryKeyPermissionCheck.ReadWriteSubTree);

But still cannot access to the registry key if I am an non-admin user.

How to allow non-admin user have write access to the registry key under my software ? Like adding a license ?

The first thing to point out is why do you have a custom action instead of using the Windows Installer Registry table? A per-machine installation is "managed" or "trusted" meaning that subsequent repairs/reinstallations will automatically elevate and have permission to update the registry.

You can use the LockPermissions table in Windows Installer to relax the permissions on that registry key. Assuming it's a safe and appropriate thing to do so.

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