【问题标题】:How to get chrome version using command prompt in windows如何在 Windows 中使用命令提示符获取 chrome 版本
【发布时间】:2018-11-25 14:44:45
【问题描述】:

是否可以在 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

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

我使用的是 Windows 7。Google Chrome 版本是 67.0.3396.87。

提前致谢

【问题讨论】:

    标签: windows google-chrome command-line terminal command-prompt


    【解决方案1】:

    截至今天,user4851 仍在工作。我查看了他链接的错误报告,建议的解决方法不再对我有用。

    我的目录中存在一个新的 hkey,它允许您在不知道实际安装位​​置的情况下查询 chrome 版本:

    reg query "HKEY_CURRENT_USER\Software\Google\Chrome\BLBeacon" /v version
    

    【讨论】:

      【解决方案2】:

      有一个关于此的错误: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 cmets中还有一些其他的建议,比如查询注册表。

      更新

      Chromium 团队的某个人在错误评论线程中发布了这个“完全不受支持”的批处理文件:

      @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
      )
      

      这应该被视为目前的正确方法。

      【讨论】:

      • 非常感谢您提供这种可怕的解决方法。我讨厌 Chrome。
      【解决方案3】:

      我尝试了 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、go os/exec 等)使用它,您可以这样做,

      powershell -command "&{(Get-Item 'Absolute\path\to\chrome.exe').VersionInfo.ProductVersion}"
      

      【讨论】:

      • 在我的情况下必须删除 (x86) 部分
      • 恕我直言,这比公认的答案更好,因为它是唯一适用于任何 Chrome 或 Chromium 二进制文件的方法,即使它不是“最”安装的 Chrome。
      • 感谢@YegorAndrosov,较新的版本安装到 64 位程序目录。已更新。
      • @lenka_cizkova 这是一个Powershell脚本,我在cmd.exe中使用时遇到了你提到的错误。 powershell -command "&{(Get-Item "Absolute\path\to\chrome.exe").VersionInfo.ProductVersion}" 在 cmd 提示符下为我工作
      • 我不得不在'Absolute\path\to\chrome.exe'周围使用单引号,否则我会被Get-Item : a positional parameter cannot be found that accepts argument 'Files\Google\Chrome...拒绝
      【解决方案4】:

      仅使用命令行工具

      dir /B/AD "C:\Program Files (x86)\Google\Chrome\Application\"|findstr /R /C:"^[0-9].*\..*[0-9]$"
      78.0.3904.97
      

      仅列出 Chrome 应用程序文件夹中的目录 /AD,缩写形式为 /B

      findstr /R /C:"..." 将以下正则表达式应用于目录列表。正则表达式匹配以数字 ^[0-9] 开头并以广告数字 [0-9]$ 结尾的每个文件夹名称。 在第一个和最后一个数字之间有任何字符 .* 允许,但至少应该出现一个点 \.

      【讨论】:

      • 对不起,这个方法完全不可靠
      • 即使这样也失败了:`start chrome chrome://version'
      猜你喜欢
      • 2020-05-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-11
      • 2022-01-09
      相关资源
      最近更新 更多