如何使用Power Shell卸载Google Chrome

时间:2016-11-29 12:05:09

标签: google-chrome powershell

我正在努力编写一个PowerShell脚本,用于从我的计算机上卸载当前版本的54.0.2840.99 m Google Chrome,但无法执行此操作。我在我的脚本中使用以下代码:

$app = Get-WmiObject -Class Win32_Product | Where-Object {
$_.Name -match “Google Chrome”}
$app.Uninstall()

Chrome已安装在我的计算机上,但上面的代码未在列表中显示Google Chrome。它返回null值,无法卸载。

您能告诉我出错的地方或通过PowerShell卸载Google Chrome的其他替代解决方案吗?

2 个答案:

答案 0 :(得分:0)

Google Chrome在安装Chrome时不使用WMI。您可以使用以下命令查找版本,并使用其安装程序包卸载chrome。

(Get-ItemProperty -path 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Google Chrome').version | ForEach-Object {& ${env:ProgramFiles(x86)}\Google\Chrome\Application\$_\Installer\setup.exe --uninstall --multi-install --chrome --system-level --force-uninstall}

答案 1 :(得分:0)

我用这个:

$GoogleChrome = [CimInstance](Get-CimInstance -ClassName Win32_Product | Where-Object {$_.Name -eq 'Google Chrome'})
If ($GoogleChrome -ne $null) {
    Write-Host 'Uninstalling Google Chrome'$GoogleChrome.Version
    Invoke-CimMethod -InputObject $GoogleChrome -MethodName 'Uninstall' | Out-Null
}

搜索卸载程序所需的时间比我想要的要长,但是它适用于我们使用的64位版本的Google Chrome浏览器。