[英]Don't run specified Windows applications using c#
我想阻止访问我计算机上的某些应用程序。 我在计算机上使用了 gpedit.msc 工具的类别:不要运行特定的 windows 应用程序。 我现在正在寻找可以自动阻止 gpedit.msc 中的应用程序的 .netcore C # 算法
我使用这个代码:
public static class GPAwareHelper
{
private const String REG_PATH =
"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer";
public static Object GetGPOverride(
String keyName, Object configValue)
{
Object keyValue = null;
RegistryKey demoKey = null;
//if (isHKLM)
// // open named key in HKEY_LOCAL_MACHINE section
// demoKey = Registry.LocalMachine.OpenSubKey(REG_PATH);
//else
// // open named key in HKEY_CURRENT_USER section
demoKey = Registry.CurrentUser.OpenSubKey(REG_PATH);
if (demoKey != null)
{
// get the specified value from this key
keyValue = demoKey.GetValue(keyName);
demoKey.Close();
// check that a value was found and, if not, return `enter code here`
// the value provided in method parameters
if (keyValue != null)
{
return keyValue;
}
else
return configValue;
}
else
{
// key not found, so return value provided
// in method parameters
return configValue;
}
}
组策略是注册表项。 只需使用 .netcore 编写这些注册表项。
您可以通过添加键来阻止某些应用程序
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies
这是一个很好的介绍。
要使用 dotnet 核心编写注册表项,您必须添加 package Microsoft.Win32.Registry
dotnet add package Microsoft.Win32.Registry
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.