2017-02-12 58 views
0

加入家长控制程序的限制我有这样的代码,以在Windows中启用家长控制:如何使用WMI

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(); 
} 

通过这种方式,启用家长控制,但我怎么可以设置程序限制,以允许程序?

回答