Wrong Python Path _winreg

When I try to read a value from this key, the correct value of this key is not returned, but instead I get a different key path value?

import _winreg as wreg key = wreg.OpenKey(wreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run") print(wreg.EnumValue(key, 0)) 

And the conclusion:

 ('SunJavaUpdateSched', u'"C:\\Program Files (x86)\\Common Files\\Java\\Java Update\\jusched.exe"', 1) 

But is this value not part of the key I used? This value is not on this key, I have to get a different value. I searched where the value is from the wrong value in RegEdit and its location is in

 HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run 

When i use command line

 REG QUERY HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run 

And I get the correct conclusion ...

 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run IgfxTray REG_SZ "C:\Windows\system32\igfxtray.exe" HotKeysCmds REG_SZ "C:\Windows\system32\hkcmd.exe" Persistence REG_SZ "C:\Windows\system32\igfxpers.exe" 

Then I would try using os.popen in python ...

 import os buff = os.popen("REG QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run") print(buff.read()) 

And conclusion

 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run SunJavaUpdateSched REG_SZ "C:\Program Files (x86)\Common Files\Java\Java Update\jusched.exe" 

Why are they different? How can I get the correct value using _winreg ?

+8
python registry winreg
source share
1 answer

In WOW64, 32-bit applications consider a registry tree that is separate from the registry tree that scans 64-bit applications. Registry Reflection copies certain registry keys and values ​​between two views.

You should disable the reflection registry.

 _winreg.DisableReflectionKey() # Do stuff ... # ... # ... _winreg.EnableReflectionKey() 
+2
source share

All Articles