title: Why doesn't group policy settingS get changed?
body: <p>I am trying to change some windows settings by group policy settings using C#.<br>
  My application creates sub-keys in the  group policy objects section successfully, 
  But some times they doesn't work.<br>
  For example i am trying to disable desktop using Group policy, I take these steps :</p>
  
  <ol>
  <li>I run <code>Process monitor</code> and configure it to show me the registry changes relating to mmc.exe </li>
  <li>Then run gpedit.msc and navigate to the desired option and change it</li>
  <li><p>I copy the registry change which is shown in <code>Process monitor</code> and use it
  in my app like this :</p>
  
  <pre><code>mmc.exe  RegSetValue HKCU\Software\Microsoft\Windows\CurrentVersion\Group Policy Objects\{FD0F8A58-1909-410F-8860-4CFF7766FA89}User\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoDesktop        SUCCESS  Type: REG_DWORD, Length: 4, Data: 1
  </code></pre></li>
  </ol>
  
  <p>And use it like this : </p>
  
  <pre><code>string regPath = @"Software\Microsoft\Windows\CurrentVersion\Policies\Explorer";
  string option = "NoDesktop";
  
  SetGroupPolicySetting(regPath, option, 1);
  </code></pre>
  
  <p>SetGroupPolicySetting uses a dll which can be downloaded from <a href="http://www.lshift.net/blog/2013/03/25/programmatically-updating-local-policy-in-windows/comment-page-1" rel="nofollow">here</a> and is written like this : </p>
  
  <pre><code>private void SetGroupPolicySetting(string registryKeyPath,
                                      string option,
                                      int value ,
                                      GroupPolicySection groupPolicySection = GroupPolicySection.User)
  {
      var gpo = new ComputerGroupPolicyObject();
      RegistryKey registryKey = gpo.GetRootRegistryKey(groupPolicySection);
      registryKey.CreateSubKey(registryKeyPath).SetValue(option, value , RegistryValueKind.DWord);
      gpo.Save();
  }
  </code></pre>
  
  <p>After that , there are two subkeys created which are: </p>
  
  <pre><code>HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Group Policy Objects\{27D2FEFF-E5C6-4D8B-B657-0D1E1F2E4BAE}Machine
  </code></pre>
  
  <p>and </p>
  
  <pre><code>HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Group Policy Objects\{27D2FEFF-E5C6-4D8B-B657-0D1E1F2E4BAE}User
  </code></pre>
  
  <p>and finally the NoDesktop option in Explorer section is created in this address :</p>
  
  <pre><code>HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Group Policy Objects\{27D2FEFF-E5C6-4D8B-B657-0D1E1F2E4BAE}User\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer
  </code></pre>
  
  <p>though still its not working ! Whats wrong ? its driving me insane!</p>