如何从命令行或注册表设置获取Microsoft EDGE铬版本 [英] how to get microsoft edge chromium version from command line or registry settings
本文介绍了如何从命令行或注册表设置获取Microsoft EDGE铬版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须在python中自动获取EDGE铬浏览器版本。我尝试了此HKEY_LOCAL_MACHINESOFTWAREPoliciesMicrosoftEdge
中提到的注册表设置。但该注册表项不存在。
推荐答案
您可以通过编程方式检索Microsoft Edge Chromium版本:从Windows注册表或Windows管理规范数据库
让我们从命令行版本开始:
注册表(方法1)
reg.exe QUERY "HKEY_CURRENT_USERSoftwareMicrosoftEdgeBLBeacon" /t REG_SZ /reg:32 /v version
注册表(方法2)
reg.exe QUERY "HKEY_LOCAL_MACHINESOFTWAREWOW6432NodeMicrosoftEdgeUpdateClients{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" /t REG_SZ /reg:32 /v pv
WMI(方法3)
wmic.exe DATAFILE WHERE "NAME='C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe'" GET Version /value
这里有一个简单的Python脚本,用于从注册表(使用winreg
模块)和WMI(通过调用wmic.exe
并解析其输出)检索版本
import subprocess import winreg import re # ----- Method 1 ----- keyPath1 = r"SoftwareMicrosoftEdgeBLBeacon" key1 = winreg.OpenKey(winreg.HKEY_CURRENT_USER, keyPath1, 0, winreg.KEY_READ) edgeVersion1 = winreg.QueryValueEx(key1, "version")[0] print(f'Method #1 >>> {edgeVersion1}') # ----- Method 2 ----- keyPath2 = r"SOFTWAREWOW6432NodeMicrosoftEdgeUpdateClients{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" key2 = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, keyPath2, 0, winreg.KEY_READ) edgeVersion2 = winreg.QueryValueEx(key2, "pv")[0] print(f'Method #2 >>> {edgeVersion1}') # ----- Method 3 ----- msedgeExe = r"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" cmdArgs = ["wmic", "DATAFILE", "WHERE", r"NAME='{0}'".format(msedgeExe), "GET", "Version", "/value"] process = subprocess.check_output(cmdArgs) edgeVersion3 = re.sub("Version=", "", process.strip().decode()) print(f'Method #3 >>> {edgeVersion3}')
在Windows 10 1909版上使用Python 3.8.2进行测试
希望能有所帮助!
这篇关于如何从命令行或注册表设置获取Microsoft EDGE铬版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文