当我尝试从该键读取值时,不会返回该键的正确值,而是得到不同的键路径值?
import _winreg as wreg
key = wreg.OpenKey(wreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run")
print(wreg.EnumValue(key, 0))
和输出:
('SunJavaUpdateSched', u'"C:\\Program Files (x86)\\Common Files\\Java\\Java Update\\jusched.exe"', 1)
但是这个值不是我使用的密钥的一部分吗?这个值不在这个键上,我应该得到一个不同的值。我搜索了 RegEdit 上不正确值的值所在的位置,它位于
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run
当我使用命令提示符时
REG QUERY HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
我得到了正确的输出......
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"
然后我会尝试在 python 上使用 os.popen ......
import os
buff = os.popen("REG QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run")
print(buff.read())
和输出
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
SunJavaUpdateSched REG_SZ "C:\Program Files (x86)\Common Files\Java\Java Update\jusched.exe"
为什么这些不同?如何使用 获得正确的值_winreg
?