You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用PowerShell获取Google Chrome的正确最后更新时间?

解决Chrome更新时间获取错误的问题

你当前代码取的主目录chrome.exe修改时间不准确,因为Chrome的更新机制是将新版本文件存放在Application目录下的版本号命名子文件夹中,主目录的chrome.exe只是引导程序,不会随更新改变修改时间。以下两种方法可以正确获取更新时间:

方法1:通过最新版本文件夹的修改时间获取

# 获取Chrome Application目录下所有版本号格式的子文件夹
$chromeVersionDirs = Get-ChildItem "C:\Program Files (x86)\Google\Chrome\Application\" -Directory | Where-Object { $_.Name -match '^\d+\.\d+\.\d+\.\d+$' }

# 按修改时间倒序排序,取最新的文件夹
$latestVersionDir = $chromeVersionDirs | Sort-Object LastWriteTime -Descending | Select-Object -First 1

if ($latestVersionDir) {
    $lastUpdated = $latestVersionDir.LastWriteTime
    Write-Host "Google Chrome最后更新时间: $lastUpdated"
} else {
    Write-Host "未找到Chrome版本文件夹"
}

方法2:通过注册表读取更新记录

Chrome会在注册表中存储更新的时间信息,可直接读取转换:

$regPath = "HKLM:\SOFTWARE\Wow6432Node\Google\Update\Clients\{8A69D345-D564-463c-AFF1-A69D9E530F96}"
$lastUpdateBinary = Get-ItemProperty -Path $regPath -Name "LastSuccessfulUpdateTime" -ErrorAction SilentlyContinue

if ($lastUpdateBinary) {
    # 将二进制FILETIME格式转换为DateTime
    $fileTime = [System.BitConverter]::ToInt64($lastUpdateBinary.LastSuccessfulUpdateTime, 0)
    $lastUpdated = [System.DateTime]::FromFileTime($fileTime)
    Write-Host "Google Chrome最后更新时间: $lastUpdated"
} else {
    Write-Host "注册表中未找到更新时间记录"
}

内容的提问来源于stack exchange,提问作者snehasish nandy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.23 12:27:13