I’m having difficulty changing the DisableTaskMgr value in the registry. Here’s what I’m trying so far:
RegistryKey taskMgr = Registry.CurrentUser.OpenSubKey("Software").OpenSubKey("Microsoft").OpenSubKey("Windows").OpenSubKey("CurrentVersion").OpenSubKey("Policies");
string[] subKeys = taskMgr.GetSubKeyNames();
bool foundSystemKey = false;
foreach (string s in subKeys)
if (s == "System")
{
foundSystemKey = true;
break;
}
if (!foundSystemKey)
{
taskMgr = taskMgr.CreateSubKey("System");
// here is where I'm getting the exception even when I do OpenSubkey("Policies" , true)
}
taskMgr.OpenSubKey("System", true);
taskMgr.SetValue("DisableTaskMgr", 1); // 0 to enable, 1 to disable.
I’ve also tried the following, am seeing the same error get thrown while executing the last line:
RegistrySecurity myRegSecurity = taskMgr.GetAccessControl();
string User = System.Environment.UserName;
myRegSecurity.ResetAccessRule(new RegistryAccessRule(User, RegistryRights.FullControl , AccessControlType.Allow));
taskMgr.SetAccessControl(myRegSecurity); // right here ..
Do you have any explanation as to what’s going wrong? Thanks in advance 🙂
You likely have a permissions issue.
Open regedit, find your key (‘Policies’)
Right click on the key and select ‘Permissions’
Permissions my be inherited, but try adding “Everyone” and re-run your code. If it works, remove “Everyone” and decide on a new group name, add the new group to either the domain, or the local machine. Then add the new group to the key and then add all users who need the permissions to the new group.