How do I ask for an elevation for Registry access to HKLM? I'd like to add EnableLinkedConnections to "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\". I also don't want to use a manifest file. Ive tried the below code but it doesn't seem to help.
RegistryPermission f = new RegistryPermission(
RegistryPermissionAccess.Create,
@"HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\
Policies\System\EnableLinkedConnections\1");
f.Demand();
Can anyone tell me what I'm doing wrong please? Thanks
Use a link demand. Decorate your function with something like:[SecurityPermissionAttribute(SecurityAction.RequestMinimum, Assertion = true)]
http://msdn.microsoft.com/en-us/library/system.security.permissions.securitypermissionattribute.aspx
http://msdn.microsoft.com/en-us/library/system.security.permissions.securitypermission.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With