Click here to Skip to main content
15,894,825 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
private void Button10_Click(object sender, EventArgs e)
{
    Counter = 60;            
    try
    {
        if (voldis.Checked)
        {
            RegistryKey systemRegistry = Registry.CurrentUser.CreateSubKey("\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer");
            systemRegistry.SetValue("NoDrives", 0x3ffffff);
        }
        else if (volena.Checked)
        {
            RegistryKey systemRegistry = Registry.CurrentUser.CreateSubKey("\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer");
            systemRegistry.SetValue("NoDrives", 0);
        }
    }
    catch (Exception)
    {
        MessageBox.Show("Run this application as Admin to Enable or Disable", "@Need Administrator@");
    }
    DialogResult dialogResult = MessageBox.Show("PC have to reboot for effective", "Attention", MessageBoxButtons.YesNo);
    if (dialogResult == DialogResult.Yes)
    {
        Process.Start("shutdown", "-R -t 00"); //>>>how to write a code to take immediate effect without restart pc
    }
}
Posted
Updated 18-Nov-15 16:36pm
v2

1 solution

The setting your changing is best set using Group Policy, not your code.

Also, I don't think you can change that setting and have it take effect without restarting Explorer. That just means killing the Explorer.exe process and restarting it as the person who logged in, not as an admin.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900