【问题标题】:Programmatically disable Taskmanager (ctrl+alt+del )以编程方式禁用任务管理器 (ctrl+alt+del)
【发布时间】:2019-03-20 09:24:21
【问题描述】:

我目前正在开发一个应用程序来更轻松地配置 Win10 IoT 机器。 想象一下,一个用户在使用自定义 shell 并且几乎所有预定义的快捷方式都被禁用,因此他只能使用生产应用程序。 然而,为了切换用户和配置系统,“Win+L”必须保持启用。 现在在出现的“Win+L”屏幕中,他仍然可以找到进入任务管理器的选项(这是不希望的)。 管理员可以防止这种情况发生是使用 gpedit 并更改机器上的 ctrl+alt+del 选项。 这正是我想要做的。

Programmatically disabling Taskmanager using c#

非常接近,但此注册表项仅适用于当前登录的用户,在我的例子中是管理员,因为配置工具需要管理权限(可以配置 UWF 过滤器等)。

如果我在 LocalMachine 而不是 CurrentUser 中尝试相同的操作,注册表项会按预期创建,但它根本没有效果。

提前感谢您的帮助。

【问题讨论】:

  • 您可以使用reg load 或各种winapi 方法加载其他用户的注册表配置单元
  • @Absinthe 我不认为是 - 这个问题是关于如何为 当前 用户禁用任务管理器,而不是为其他用户禁用。
  • @Absinthe,我发布了完全相同的链接,并解释了为什么它不是我所需要的。
  • 您是否了解过 Windows Kiosk 模式?

标签: c# registry taskmanager group-policy


【解决方案1】:

我找到了实现我想要的方法:

public void SetTaskManager(bool enable)
    {
      // Load settings of desired user via UserName property
      using (PowerShell PowerShellInstance = PowerShell.Create())
      {
        var command = Properties.Settings.Default.LoadRegistryOfUser;
        command = command.Replace("USERNAME", UserName);
        PowerShellInstance.AddScript(command);
        var res = PowerShellInstance.Invoke();
      }

      // Create the key and entry for the registry or delete it if
      // enable == true
      RegistryKey objRegistryKey = Registry.Users.CreateSubKey(
         UserName + @"\Software\Microsoft\Windows\CurrentVersion\Policies\System");
      if (enable && objRegistryKey.GetValue("DisableTaskMgr") != null)
        objRegistryKey.DeleteValue("DisableTaskMgr");
      else
        objRegistryKey.SetValue("DisableTaskMgr", "1", RegistryValueKind.DWord);

      objRegistryKey.Close();

      // Close the registry of the user, otherwise he cant log on
      using (PowerShell PowerShellInstance = PowerShell.Create())
      {
        var command = Properties.Settings.Default.CloseRegistryOfUser;
        command = command.Replace("USERNAME", UserName);
        PowerShellInstance.AddScript(command);
        var res = PowerShellInstance.Invoke();
      }
    }

脚本:

LoadRegistryOfUser: reg load HKU\USERNAME C:\users\USERNAME\NTUSER.DAT

关闭注册用户: reg 卸载 HKU\USERNAME

它有点老套,但到目前为止我发现的唯一方法。 希望这会有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-02-27
    • 2019-11-02
    • 2013-05-24
    • 2012-07-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多