如何在Windows中使用命令提示符获取Chrome版本

Sar*_*ath 7 windows terminal command-line google-chrome command-prompt

是否可以在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
Run Code Online (Sandbox Code Playgroud)

当我这样做时,浏览器实例正在打开。我应该使用什么标志来获取版本。

我使用的是Windows7。Chrome浏览器的版本是67.0.3396.87。

提前致谢

Kil*_*ian 13

截止到今天,user4851仍在工作。我看了看他的链接错误报告,而建议的解决方法对我来说不再起作用。

总而言之,我的目录中存在一个新的hkey,您可以在不知道实际安装位​​置的情况下查询chrome版本:

reg query "HKEY_CURRENT_USER\Software\Google\Chrome\BLBeacon" /v version
Run Code Online (Sandbox Code Playgroud)


use*_*851 11

关于此的错误已提交: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
Run Code Online (Sandbox Code Playgroud)

它打印

Version=67.0.3396.99
Run Code Online (Sandbox Code Playgroud)

由一些空白行包围。

错误注释中还有其他一些建议,例如查询注册表。

更新资料

Chromium小组的某人在Bug评论线程中发布了此“完全不受支持”的批处理文件:

@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
)
Run Code Online (Sandbox Code Playgroud)

暂时应该将其视为正确的方法。


use*_*134 7

我尝试了 Kilian 的答案,但是在我的情况下,我是通过服务远程对一堆机器运行它,所以我认为 HKEY_CURRENT_USER 无效:

ERROR: The system was unable to find the specified registry key or value.
Run Code Online (Sandbox Code Playgroud)

假设您知道 exe 在哪里,您可以尝试不同的方法并读取 exe 文件的 version 属性:

# 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
Run Code Online (Sandbox Code Playgroud)

  • @lenka_cizkova 这是一个Powershell脚本,我在cmd.exe中使用它时遇到了你提到的错误。`powershell -command "&{(Get-Item "Absolute\path\to\chrome.exe").VersionInfo.ProductVersion}"` 从 cmd 提示符为我工作 (2认同)