title: Windows preventing reg query on HKLM; returns HKCU instead
body: <p>I'm using ActivePython 2.5 to read the registry for entries that pGina makes. Specifically, the entries concerning which GIDs are allowed on the computer. This information can periodically change for each computer as edited through pGina, so I want my Python script to be able to check these values each time.</p>
  
  <p>Easy enough. The following Windows command will get that information for me:</p>
  
  <pre><code>reg query HKLM\Software\pGina\ldapauth\
  </code></pre>
  
  <p>...except when I run it with Python, I get this:</p>
  
  <pre><code>&gt;&gt;&gt; import subprocess
  &gt;&gt;&gt; command = 'reg query HKLM\Software\pGina\ldapauth'
  &gt;&gt;&gt; ldapauth = subprocess.Popen(command, shell=False, stdout=subprocess.PIPE).communicate()[0]
  ERROR: The system was unable to find the specified registry key or value.
  </code></pre>
  
  <p>So when I run 'reg query HKLM\Software' through Python, it spits out a list of the keys and values under HK <strong>CU</strong>\Software, rather than HKLM.</p>
  
  <p>I'm running Python as Administrator (confirmed by using getpass.getuser()) and when I run the same command from a batch script, I get the correct listing under HKLM. However, when I call the batch script from Python, back to the ole' HKCU results.</p>
  
  <p>So, I'm a bit stuck. Does anyone have any insight?</p>
  
  <p>EDIT: As detailed later, I am running Windows 7 64-bit and I have tried the _winreg methods, including the optional 4th "sam" argument in OpenKey.</p>