I use this code to get the installed .NET Version on a remote machine. With Windows 7 it works perfect but with Windows 10 the following exception throws
System.Security.SecurityException: Requested registry access is not allowed.
Code example
using (RegistryKey remoteHklm = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, hostName))
{
using (RegistryKey serviceKey = remoteHklm.OpenSubKey(@"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full", true))
{
if (serviceKey != null)
{
version = serviceKey.GetValue("Version").ToString();
}
else
{
version = "error on get version from registry";
}
}
}
You have with Windows 10 no write Access to this registry key. Change the second OpenSubKey
parameter to false
, you can check in Registry Editor the permission of the key.
using (RegistryKey serviceKey = remoteHklm.OpenSubKey(@"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full", false))
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.