title: python winreg unable to write to HKEY_CURRENT_USER
body: <p>When using the following code block, I cannot write to HKEY_CURRENT_USER, but writing to HKEY_LOCAL_MACHINE is fine. There are no errors reported when attempting to write to HKEY_CURRENT_USER. There is no endpoint protection installed that would restrict writing to the registry.</p>
  <p>Using python 3.9.1 and psutil 5.8.0 on Windows 10 64-bit and script is being executed as administrator.</p>
  <pre><code>import winreg
  #HKEY_CURRENT_USER
  with winreg.ConnectRegistry(None, winreg.HKEY_CURRENT_USER) as root:
      with winreg.CreateKeyEx(root, 'Software\AAA', 0, access = winreg.KEY_WOW64_64KEY | winreg.KEY_WRITE) as key:
          winreg.SetValueEx(key, &quot;PATH&quot;, 0, winreg.REG_SZ, 'test')
  
  # HKEY_LOCAL_MACHINE
  with winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE) as root:
      with winreg.CreateKeyEx(root, 'Software\AAA', 0, access = winreg.KEY_WOW64_64KEY | winreg.KEY_WRITE) as key:
          winreg.SetValueEx(key, &quot;PATH&quot;, 0, winreg.REG_SZ, 'test')
  </code></pre>
  <p><a href="https://i.stack.imgur.com/0rghC.png" rel="nofollow noreferrer">HKEY_CURRENT_USER</a></p>
  <p><a href="https://i.stack.imgur.com/I0DDs.png" rel="nofollow noreferrer">HKEY_LOCAL_MACHINE</a></p>
  <pre><code>C:\Users\admin\source\repos&gt; python3 test.py
  
  C:\Users\admin\source\repos&gt;
  </code></pre>
  <p>Anyone have an idea of what I'm missing?</p>
  <p>thanks!</p>