0

I have this code to enable parental control in 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();
}

By this, parental control enabled, but how can i set Program limits to define allowed programs?

Mohsen.Sharify
  • 259
  • 4
  • 11

1 Answers1

0

I found that it is related to RestrictRun registry key:

SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer

it explaned in this address: https://www.howtogeek.com/howto/8739/restrict-users-to-run-only-specified-programs-in-windows-7/

Mohsen.Sharify
  • 259
  • 4
  • 11