2009-06-03 47 views
0

我已使用以下代碼來禁用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; 
+0

使用組策略對象。 Explorer識別GPO並在應用GPO時刷新策略緩存。 – 2014-01-29 15:46:42

回答

0

在更改註冊表後,您可以嘗試運行Gpupdate。理論上這應該重新加載組策略細節,並因此禁用控制面板。

+0

感謝您的迴應,Gpupdate不會工作 gpedit /目標:用戶/強制 gpedit /目標:計算機/強制 任何其他方法 – 2009-06-27 06:27:23

0

下面的代碼將禁用:

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