我有这段代码在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();
}
这样,启用了家长控制,但是如何设置程序限制来定义允许的程序?