Click here to Skip to main content
15,909,466 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
hi every one

i need to add registery key in
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies
\Explorer
using
registerykey subkey= registery.open(keypath);

but when i did that in c# i had error that i need premission
so how can i give my application administrator rights in any computer??

thanks
Posted

 
Share this answer
 
You can set up your manifest file to request such permissions, but that will generate a warning that people may choose to reject, and not run your app. You can ask them to run as admin, which has the same problem.
 
Share this answer
 
using Microsoft.Win32;
RegistryKey rKey = Registry.currentuser.OpenSubKey("\Software\Microsoft\Windows\CurrentVersion\Policies
\Explorer");
if (rKey == null)
{
rKey = Registry.currentuser.CreateSubKey("\Software\Microsoft\Windows\CurrentVersion\Policies
\Explorer");
}
RegistryKey key = Registry.currentuser.OpenSubKey("\Software\Microsoft\Windows\CurrentVersion\Policies
\Explorer", true);
string sysname = Environment.MachineName;
key.SetValue("Sysname", sysname, RegistryValueKind.String);


Regards
S.Murugesan
Mr.s.murugesan@gmail.com
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900