如何在 windows 中使用命令提示符获取 chrome 版本
How to get chrome version using command prompt in windows
是否可以在 windows 中使用命令提示符安装版本 chrome 版本?
尝试过,
"C:\Program Files\Google\Chrome\Application\chrome.exe" -version
"C:\Program Files\Google\Chrome\Application\chrome.exe" --version
"C:\Program Files\Google\Chrome\Application\chrome.exe" -product-version
"C:\Program Files\Google\Chrome\Application\chrome.exe" --product-version
当我这样做时,浏览器实例正在打开。我应该使用什么标志来获取版本。
我用的是Windows7.GoogleChrome版本是67.0.3396.87.
提前致谢
有一个关于此的错误:https://bugs.chromium.org/p/chromium/issues/detail?id=158372
原始答案(但请参阅下面的更新)
对我有用的是
wmic datafile where name="C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" get Version /value
它打印
Version=67.0.3396.99
被一些空行包围。
bug评论中还有一些其他的建议,比如查询注册表。
更新
Chromium 团队的某人在错误评论线程中发布了这个 "totally unsupported" 批处理文件:
@ECHO OFF
:: Look for machine-wide Chrome installs (stable, Beta, and Dev).
:: Get the name, running version (if an update is pending relaunch), and
:: installed version of each.
FOR %%A IN (
{8A69D345-D564-463c-AFF1-A69D9E530F96},
{8237E44A-0054-442C-B6B6-EA0509993955},
{401C381F-E0DE-4B85-8BD8-3F3F14FBDA57}) DO (
reg query HKLM\Software\Google\Update\Clients\%%A /v name /reg:32 2> NUL
reg query HKLM\Software\Google\Update\Clients\%%A /v opv /reg:32 2> NUL
reg query HKLM\Software\Google\Update\Clients\%%A /v pv /reg:32 2> NUL
)
:: Look for Chrome installs in the current user's %LOCALAPPDATA% directory
:: (stable, Beta, Dev, and canary).
:: Get the name, running version (if an update is pending relaunch), and
:: installed version of each.
FOR %%A IN (
{8A69D345-D564-463c-AFF1-A69D9E530F96},
{8237E44A-0054-442C-B6B6-EA0509993955},
{401C381F-E0DE-4B85-8BD8-3F3F14FBDA57},
{4ea16ac7-fd5a-47c3-875b-dbf4a2008c20}) DO (
reg query HKCU\Software\Google\Update\Clients\%%A /v name /reg:32 2> NUL
reg query HKCU\Software\Google\Update\Clients\%%A /v opv /reg:32 2> NUL
reg query HKCU\Software\Google\Update\Clients\%%A /v pv /reg:32 2> NUL
)
这可能应该被视为目前的正确方法。
截至今天,user4851 仍在工作。我查看了他链接的错误报告,建议的解决方法不再适合我。
无论如何,我的目录中存在一个新的 hkey,它允许您查询 chrome 版本而无需知道实际安装位置:
reg query "HKEY_CURRENT_USER\Software\Google\Chrome\BLBeacon" /v version
我尝试了 Kilian 的回答,但就我而言,我是 运行 通过服务远程针对一堆机器,所以我认为 HKEY_CURRENT_USER 无效:
ERROR: The system was unable to find the specified registry key or value.
假设你知道 exe 在哪里,你可以尝试不同的方法并读取 exe 文件的版本 属性:
# Powershell
# Older versions install to the 32-bit directory
(Get-Item "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe").VersionInfo
# Newer versions use the 64-bit directory
(Get-Item "C:\Program Files\Google\Chrome\Application\chrome.exe").VersionInfo
ProductVersion FileVersion FileName
-------------- ----------- --------
76.0.3809.100 76.0.3809.100 C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
要在 cmd.exe 中或通过任何子进程调用(python、转到 os/exec 等)使用它,您可以这样做,
powershell -command "&{(Get-Item 'Absolute\path\to\chrome.exe').VersionInfo.ProductVersion}"
仅使用命令行工具
dir /B/AD "C:\Program Files (x86)\Google\Chrome\Application\"|findstr /R /C:"^[0-9].*\..*[0-9]$"
78.0.3904.97
仅以 /B
.
的形式列出 Chrome 应用程序文件夹中的目录 /AD
findstr /R /C:"..."
将以下正则表达式应用于目录列表。正则表达式匹配每个以数字 ^[0-9]
开头并以广告数字 [0-9]$
结尾的文件夹名称。
在第一个和最后一个数字之间可以有任何字符 .*
但至少应该出现一个点 \.
对我有用,但是如果允许您假设 Chrome 是 %PATH%
的一部分(如果您可以打开命令提示符并键入 chrome
启动浏览器),就可以大大简化
您可以在 Powershell 中键入 (Get-Command "chrome").Version.ToString()
或者从 cmd.exe 你可以输入 powershell -c "(Get-Command "chrome").Version.ToString()"
(与 Chromium 相同,只需替换命令名称)
是否可以在 windows 中使用命令提示符安装版本 chrome 版本?
尝试过,
"C:\Program Files\Google\Chrome\Application\chrome.exe" -version
"C:\Program Files\Google\Chrome\Application\chrome.exe" --version
"C:\Program Files\Google\Chrome\Application\chrome.exe" -product-version
"C:\Program Files\Google\Chrome\Application\chrome.exe" --product-version
当我这样做时,浏览器实例正在打开。我应该使用什么标志来获取版本。
我用的是Windows7.GoogleChrome版本是67.0.3396.87.
提前致谢
有一个关于此的错误:https://bugs.chromium.org/p/chromium/issues/detail?id=158372
原始答案(但请参阅下面的更新)
对我有用的是
wmic datafile where name="C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" get Version /value
它打印
Version=67.0.3396.99
被一些空行包围。
bug评论中还有一些其他的建议,比如查询注册表。
更新
Chromium 团队的某人在错误评论线程中发布了这个 "totally unsupported" 批处理文件:
@ECHO OFF
:: Look for machine-wide Chrome installs (stable, Beta, and Dev).
:: Get the name, running version (if an update is pending relaunch), and
:: installed version of each.
FOR %%A IN (
{8A69D345-D564-463c-AFF1-A69D9E530F96},
{8237E44A-0054-442C-B6B6-EA0509993955},
{401C381F-E0DE-4B85-8BD8-3F3F14FBDA57}) DO (
reg query HKLM\Software\Google\Update\Clients\%%A /v name /reg:32 2> NUL
reg query HKLM\Software\Google\Update\Clients\%%A /v opv /reg:32 2> NUL
reg query HKLM\Software\Google\Update\Clients\%%A /v pv /reg:32 2> NUL
)
:: Look for Chrome installs in the current user's %LOCALAPPDATA% directory
:: (stable, Beta, Dev, and canary).
:: Get the name, running version (if an update is pending relaunch), and
:: installed version of each.
FOR %%A IN (
{8A69D345-D564-463c-AFF1-A69D9E530F96},
{8237E44A-0054-442C-B6B6-EA0509993955},
{401C381F-E0DE-4B85-8BD8-3F3F14FBDA57},
{4ea16ac7-fd5a-47c3-875b-dbf4a2008c20}) DO (
reg query HKCU\Software\Google\Update\Clients\%%A /v name /reg:32 2> NUL
reg query HKCU\Software\Google\Update\Clients\%%A /v opv /reg:32 2> NUL
reg query HKCU\Software\Google\Update\Clients\%%A /v pv /reg:32 2> NUL
)
这可能应该被视为目前的正确方法。
截至今天,user4851 仍在工作。我查看了他链接的错误报告,建议的解决方法不再适合我。
无论如何,我的目录中存在一个新的 hkey,它允许您查询 chrome 版本而无需知道实际安装位置:
reg query "HKEY_CURRENT_USER\Software\Google\Chrome\BLBeacon" /v version
我尝试了 Kilian 的回答,但就我而言,我是 运行 通过服务远程针对一堆机器,所以我认为 HKEY_CURRENT_USER 无效:
ERROR: The system was unable to find the specified registry key or value.
假设你知道 exe 在哪里,你可以尝试不同的方法并读取 exe 文件的版本 属性:
# Powershell
# Older versions install to the 32-bit directory
(Get-Item "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe").VersionInfo
# Newer versions use the 64-bit directory
(Get-Item "C:\Program Files\Google\Chrome\Application\chrome.exe").VersionInfo
ProductVersion FileVersion FileName
-------------- ----------- --------
76.0.3809.100 76.0.3809.100 C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
要在 cmd.exe 中或通过任何子进程调用(python、转到 os/exec 等)使用它,您可以这样做,
powershell -command "&{(Get-Item 'Absolute\path\to\chrome.exe').VersionInfo.ProductVersion}"
仅使用命令行工具
dir /B/AD "C:\Program Files (x86)\Google\Chrome\Application\"|findstr /R /C:"^[0-9].*\..*[0-9]$"
78.0.3904.97
仅以 /B
.
/AD
findstr /R /C:"..."
将以下正则表达式应用于目录列表。正则表达式匹配每个以数字 ^[0-9]
开头并以广告数字 [0-9]$
结尾的文件夹名称。
在第一个和最后一个数字之间可以有任何字符 .*
但至少应该出现一个点 \.
%PATH%
的一部分(如果您可以打开命令提示符并键入 chrome
启动浏览器),就可以大大简化
您可以在 Powershell 中键入 (Get-Command "chrome").Version.ToString()
或者从 cmd.exe 你可以输入 powershell -c "(Get-Command "chrome").Version.ToString()"
(与 Chromium 相同,只需替换命令名称)