如何使用 wmi 在家长控制中添加程序限制
How add program limits in parental control using wmi
我有此代码可以在 windows 中启用家长控制:
System.Security.Principal.NTAccount myNTAccount = new System.Security.Principal.NTAccount("username");
System.Security.Principal.SecurityIdentifier mySecurityIdentifier = (System.Security.Principal.SecurityIdentifier)myNTAccount.Translate(typeof(System.Security.Principal.SecurityIdentifier));
ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\CIMV2\Applications\WindowsParentalControls", "SELECT * FROM WpcUserSettings where SID='" + mySecurityIdentifier.ToString() + "'");
foreach (ManagementObject queryObj in searcher.Get())
{
queryObj["AppRestrictions"] = true;
queryObj["HourlyRestrictions"] = true;
queryObj["LoggingRequired"] = false;
//queryObj["LogonHours"] = ;
//queryObj["OverrideRequests"] = ;
queryObj["WpcEnabled"] = true;
queryObj.Put();
}
至此,家长控制已启用,但我如何设置程序限制以定义允许的程序?
我发现它与 RestrictRun 注册表项有关:
SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer
它在这个地址中解释道:
https://www.howtogeek.com/howto/8739/restrict-users-to-run-only-specified-programs-in-windows-7/
我有此代码可以在 windows 中启用家长控制:
System.Security.Principal.NTAccount myNTAccount = new System.Security.Principal.NTAccount("username");
System.Security.Principal.SecurityIdentifier mySecurityIdentifier = (System.Security.Principal.SecurityIdentifier)myNTAccount.Translate(typeof(System.Security.Principal.SecurityIdentifier));
ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\CIMV2\Applications\WindowsParentalControls", "SELECT * FROM WpcUserSettings where SID='" + mySecurityIdentifier.ToString() + "'");
foreach (ManagementObject queryObj in searcher.Get())
{
queryObj["AppRestrictions"] = true;
queryObj["HourlyRestrictions"] = true;
queryObj["LoggingRequired"] = false;
//queryObj["LogonHours"] = ;
//queryObj["OverrideRequests"] = ;
queryObj["WpcEnabled"] = true;
queryObj.Put();
}
至此,家长控制已启用,但我如何设置程序限制以定义允许的程序?
我发现它与 RestrictRun 注册表项有关:
SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer
它在这个地址中解释道: https://www.howtogeek.com/howto/8739/restrict-users-to-run-only-specified-programs-in-windows-7/