简体   繁体   中英

how to get registry key without having administrator rights in windows 7 OS

In my application(windows C#.net) i am trying to get the registry key. In windows XP(with and without admin rights) it is working fine and in windows 7 with admin rights it is working fine. But in windows 7 without admin rights when i try to get the registry key, the aplication is getting crash.

I am using the following code to get the registry key

Microsoft.Win32.RegistryKey rgKey = Microsoft.Win32.Registry.LocalMachine.CreateSubKey(rgPath);

Can some help to get the registry key without admin rights in windows 7.

Thanks in Advance.

It could not be done in Windows7 without admin rights.

Here is the solution for it.

Open the project and go to proejct menu and select add new item. There will be an item with the name "Application Manifest File". Add this to your project. A file looking like xml will be opened.

Search for the following line in that file.

<requestedExecutionLevel level="asInvoker" uiAccess="false" />

and replace it with this line

<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

Save the file and rebuild the solution. Now your software will ask for the administrator rights each time before executing on Windows7.

Enjoy :)

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