Click here to Skip to main content
14,694,027 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
registerykey subkey=;

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??


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.
using Microsoft.Win32;
RegistryKey rKey = Registry.currentuser.OpenSubKey("\Software\Microsoft\Windows\CurrentVersion\Policies
if (rKey == null)
rKey = Registry.currentuser.CreateSubKey("\Software\Microsoft\Windows\CurrentVersion\Policies
RegistryKey key = Registry.currentuser.OpenSubKey("\Software\Microsoft\Windows\CurrentVersion\Policies
\Explorer", true);
string sysname = Environment.MachineName;
key.SetValue("Sysname", sysname, RegistryValueKind.String);


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