【问题标题】:disable controlpanel禁用控制面板
【发布时间】:2014-01-29 21:14:19
【问题描述】:

我已使用以下代码禁用 Windows 控制面板。它成功禁用了控制面板,但需要重新启动系统才能应用更改。有谁知道我如何可以立即将这些更改应用到控制面板,而无需重新启动系统?谁能帮帮我?

        RegistryKey RegKey = Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Policies\Explorer");
        RegKey.SetValue("NoControlPanel", true, RegistryValueKind.DWord); RegKey.Close();

        RegKey = Registry.LocalMachine.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Policies\Explorer");
        RegKey.SetValue("NoControlPanel", true, RegistryValueKind.DWord); RegKey.Close();

        //registry
        RegKey = Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\
        Group Policy Objects\LocalUser\Software\Microsoft\Windows\CurrentVersion\Policies\System");
        RegKey.SetValue("DisableRegistryTools", true, RegistryValueKind.DWord); RegKey.Close();

        RegKey = Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Policies\System");
        RegKey.SetValue("DisableRegistryTools", true, RegistryValueKind.DWord); RegKey.Close();
        return true;

【问题讨论】:

  • 使用组策略对象。资源管理器识别 GPO 并在应用 GPO 时刷新策略缓存。

标签: c# windows controlpanel


【解决方案1】:

您可以在更改注册表后尝试运行Gpupdate。理论上,这应该重新加载组策略详细信息,因此禁用控制面板。

【讨论】:

  • 感谢您的回复,Gpupdate 无法正常工作 gpedit /Target:User /force gpedit /Target:computer /force 任何其他方法
【解决方案2】:

以下代码将禁用:

Microsoft.Win32.RegistryKey regkey = Microsoft.Win32.Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Policies\Explorer");
                regkey.SetValue("NoControlPanel", true, Microsoft.Win32.RegistryValueKind.DWord);
                regkey.Close();

            regkey = Microsoft.Win32.Registry.LocalMachine.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Policies\Explorer");
            regkey.SetValue("NoControlPanel", true, Microsoft.Win32.RegistryValueKind.DWord);
            regkey.Close();

以及重新启用的代码:

Microsoft.Win32.RegistryKey regkey = Microsoft.Win32.Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Policies\Explorer");
                regkey.SetValue("NoControlPanel", false, Microsoft.Win32.RegistryValueKind.DWord);
                regkey.Close();

            regkey = Microsoft.Win32.Registry.LocalMachine.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Policies\Explorer");
            regkey.SetValue("NoControlPanel", false, Microsoft.Win32.RegistryValueKind.DWord);
            regkey.Close();

【讨论】:

    猜你喜欢
    • 2016-12-18
    • 1970-01-01
    • 1970-01-01
    • 2015-01-03
    • 2015-12-22
    • 1970-01-01
    • 2013-09-17
    • 1970-01-01
    • 2020-05-05
    相关资源
    最近更新 更多