示例#1
0
 public void toggleTSK(bool enable)
 {
     if (enable)
     {
         try
         {
             // System.Windows.Forms.MessageBox.Show("Task manager enable");
             ComputerGroupPolicyObject.SetPolicySetting("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System!DisableTaskMgr", "0", RegistryValueKind.DWord);
         }
         catch (Exception ex)
         {
             System.Windows.Forms.MessageBox.Show("Task manager enable" + ex);
         }
     }
     else
     {
         try
         {
             // System.Windows.Forms.MessageBox.Show("Task manager disable" );
             ComputerGroupPolicyObject.SetPolicySetting("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System!DisableTaskMgr", "1", RegistryValueKind.DWord);
         }
         catch (Exception ex)
         {
             System.Windows.Forms.MessageBox.Show("Task manager edisable" + ex);
         }
     }
 }
示例#2
0
 // edit group policy to disable Registry editor
 public static void PreventAccessRegistryEditor(bool enable)
 {
     if (enable == true)
     {
         ComputerGroupPolicyObject.SetPolicySetting(@"HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System!DisableRegistryTools", "1", RegistryValueKind.DWord);
     }
     else
     {
         ComputerGroupPolicyObject.SetPolicySetting(@"HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System!DisableRegistryTools", "0", RegistryValueKind.DWord);
     }
 }
示例#3
0
 /// <summary>
 /// Disable or enable task manager. need to restart to confirm
 /// </summary>
 /// <param name="enable"></param> if enable = true => delete registry and restart
 public static void SetTaskManager(bool enable)
 {
     //RegistryKey objRegistryKey = Registry.CurrentUser.CreateSubKey(
     //    @"Software\Microsoft\Windows\CurrentVersion\Policies\System");
     //if (enable && objRegistryKey.GetValue("DisableTaskMgr") != null)
     //    objRegistryKey.DeleteValue("DisableTaskMgr");
     //else
     //    objRegistryKey.SetValue("DisableTaskMgr", "1");
     //objRegistryKey.Close();
     if (enable == true)
     {
         ComputerGroupPolicyObject.SetPolicySetting(@"HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System!DisableTaskMgr", "0", RegistryValueKind.DWord);
     }
     else
     {
         ComputerGroupPolicyObject.SetPolicySetting(@"HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System!DisableTaskMgr", "1", RegistryValueKind.DWord);
     }
 }