Requested registry access is not allowed
app.manifest
should be like this:
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app" />
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
</asmv1:assembly>
Requested registry access is not allowed. even with signed exe and admin Privileged in manifest
I found the problem but I don't know why access to this address is impossible
Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}\Properties
Registry Error on Regedit
Visual Studio Debug
I fixed my code with regex
static string GetDeviceGuid()
{
const string AdapterKey = "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002BE10318}";
RegistryKey regAdapters = Registry.LocalMachine.OpenSubKey(AdapterKey);
string[] keyNames = regAdapters.GetSubKeyNames();
foreach (string x in keyNames) {
Console.WriteLine(x);
}
string devGuid = "";
Regex rx = new Regex(@"\d{4}",
RegexOptions.Compiled | RegexOptions.IgnoreCase);
foreach (string x in keyNames)
{
if (!rx.IsMatch(x)) {
continue;
}
RegistryKey regAdapter = regAdapters.OpenSubKey(x);
object id = regAdapter.GetValue("ComponentId");
if (id != null && id.ToString() == "tap0901") devGuid = regAdapter.GetValue("NetCfgInstanceId").ToString();
}
return devGuid;
}
Run as administrator, but still requested registry access is not allowed
If you run regedit and navigate to the key that you are trying to access with your script, you can right click on it and view the permissions. You can see on that key what permissions Administrator has (Full Control, Read, Special Permissions)
Related Topics
When Is a Static Constructor Called in C#
Two Different Dll with Same Namespace
Regular Expression to Remove HTML Tags
Transparent Background Image for Form - Smooth Edge Shape for the Form
Gradient Circles for Map Generator
Oledbcommand Parameters Order and Priority
Adding Multiple Parameterized Variables to a Database in C#
What Are the True Benefits of Expandoobject
Get Mime Type from Filename Extension
Most Efficient Way to Remove Special Characters from String
View/Edit Id3 Data for Mp3 Files
Is There a .Net/C# Wrapper for SQLite
Deserialize Collection of Interface-Instances
Write a Well Designed Async/Non-Async API
How to Get Difference Between Two Dates in Year/Month/Week/Day