Enable/Disable TaskManager

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-01 11:05:11

Yes, delete will work. Means, use this code to toggle:

    public void ToggleTaskManager()
    {
        RegistryKey objRegistryKey = Registry.CurrentUser.CreateSubKey(
            @"Software\Microsoft\Windows\CurrentVersion\Policies\System");
        if (objRegistryKey.GetValue("DisableTaskMgr") == null)
            objRegistryKey.SetValue("DisableTaskMgr", "1");
        else
            objRegistryKey.DeleteValue("DisableTaskMgr");
        objRegistryKey.Close();
    }

or this code to set:

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

Try Deleting the Key instead of setting the value to False

Try this:

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

For Enable/Desable: (Sorry, my English is very bad...)

 private void Form1_KeyDown(object sender, KeyEventArgs e)
    {
        switch (e.KeyCode)
        {
            case Keys.F1:
                {
                    SetTaskManager(Convert.ToBoolean(1));
                }
                break;
        }

Note: You must have administrator access to run the program.

answer 4 is Okey But Uu need one more litte code this %100 true (RegistryValueKind.DWord) ;

RegistryKey objRegistryKey = Registry.CurrentUser.CreateSubKey(
        @"Software\Microsoft\Windows\CurrentVersion\Policies\System");
        if (objRegistryKey.GetValue("DisableTaskMgr") == null)
            objRegistryKey.SetValue("DisableTaskMgr", "1", RegistryValueKind.DWord);
        else
            objRegistryKey.DeleteValue("DisableTaskMgr");
        objRegistryKey.Close(); 

for disabling TaskManager you must set a DWord string in Registry( User Local Machine instead of Current User). Use following code.( It not working in windows 7)

Microsoft.Win32.RegistryKey key;
key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System",true);
key.SetValue("DisableTaskMgr", "1", RegistryValueKind.DWord);
key.Close();

for That user application must run under Admin Permission. change following change in app.manifest for using application in Admin Permission

 <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!