Uninstall Chrome silently using Powershell

15,440

If it's an msi you can use uninstall-package:

get-package *chrome* | uninstall-package -whatif
Share:
15,440
Andrew
Author by

Andrew

Updated on June 14, 2022

Comments

  • Andrew
    Andrew almost 2 years

    I have the following PowerShell script, which I am using to get the uninstall string for Google Chrome, and then I want to uninstall it silently. Line 3 in the script will pop up the GUI uninstaller (so it seems like everything is correct thus far), but if I add "/qn" or "/quiet" to the argument list, the uninstall doesn't seem to run at all, even if I let it sit for a couple hours.

    What am I missing?

        $AppName = "Google Chrome"
        $Chrome = Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall, HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall | Get-ItemProperty | Where-Object {$_.DisplayName -match $($AppName)}
        Start-Process -Wait -FilePath MsiExec.exe -Argumentlist "/X",$Chrome.UninstallString.TrimStart("MsiExec.exe /X")
    
  • Andrew
    Andrew over 4 years
    Your first example throws a few errors. Using your second example looks like it starts a "Windows Installer" process in Task Manager, but still returns to the command prompt more or less right away, and doesn't seem to uninstall Chrome. I'm curious, what does the "/c" do?
  • Jawad
    Jawad over 4 years
    @Andrew Updated my answer. Instead of using UninstallString, use the PSPath to get the key to use for uninstall.
  • Andrew
    Andrew over 4 years
    No improvement, unfortunately. Same as before, it starts a Windows installer process and returns to the command prompt pretty much right away, but doesn't seem to do anything, even after waiting a while.
  • Andrew
    Andrew over 4 years
    Ok, I think admin rights had something to do with this, even though my username is in the local admin group on this PC. I simplified one of your suggestions to "cmd.exe /c $Chrome.UninstallString /Passive", and noticed a UAC prompt when it ran. I then changed /Passive to /qn and opened the Powershell ISE as admin, and it removed Chrome quickly and easily. Thanks again for the help!
  • Jawad
    Jawad over 4 years
    this certainly is a good approach but I'd be careful using *s :)
  • Olaf
    Olaf over 4 years
    Why? You cannot state something like this without explaining it! ;-)
  • js2010
    js2010 over 4 years
    @Jawad In case more than one thing matches. Ok, I added -whatif.