Skip to content

Instantly share code, notes, and snippets.

@chrdek
Last active March 15, 2021 12:18
Show Gist options
  • Save chrdek/c8bff7a369251adea055b4a966d549c4 to your computer and use it in GitHub Desktop.
Save chrdek/c8bff7a369251adea055b4a966d549c4 to your computer and use it in GitHub Desktop.
Script for uninstall, downgrade chrome to earlier versions, locks future updates.
<#
# chrome_downgrade.ps1
#
# Script used for downgrading current chrome installation to earlier instances (recommended up to v83+).
#
# Used for renaming current system configuration and sets
# appropriate setting for using chrome with older version.
#
# WARNING: This script also will disable any future updates on chrome
# so that the downgraded version is locked to the latest installation.
#
# Just run the ps1 file from the command line to perform required operations.
#
# Script does not need to run with administrative priviledge, elevation
# is triggered where appropriate (with user interaction).
#
#>
Write-Host -ForegroundColor DarkYellow -BackgroundColor Black "Downgrading x86 - Chrome Instance..`r`n" -Verbose;
Write-Warning -Message "[ $((Get-Date).Hour):$((Get-Date).Minute):$((Get-Date).Second) ]`tModifying file system for changes" -Verbose;
Start-Sleep 3;
Write-Host "..DONE.."
Write-Warning -Message "[ $((Get-Date).Hour):$((Get-Date).Minute):$((Get-Date).Second) ]`tUninstalling Chrome"
# Disable external updates for latest chrome installs..
Start-Sleep 2;
Write-Host -ForegroundColor DarkYellow -BackgroundColor Black "`r`nAdditional Registry Changes..";
# Disable updates main google policy per x64, x86 registry instance (s).
$regscript = @'
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Policies\Google\Update]
"AutoUpdateCheckPeriodMinutes"=dword:00000000
"DisableAutoUpdateChecksCheckboxValue"=dword:00000001
"UpdateDefault"=dword:00000000
"Update{8A69D345-D564-463C-AFF1-A69D9E530F96}"=dword:00000000
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Update]
"AutoUpdateCheckPeriodMinutes"=dword:00000000
"DisableAutoUpdateChecksCheckboxValue"=dword:00000001
"UpdateDefault"=dword:00000000
"Update{8A69D345-D564-463C-AFF1-A69D9E530F96}"=dword:00000000
'@;
# bulk entries import via command line..
$regscript | Add-content -Path ".\chrome_update_remove.reg" | Out-Null;
$is64bit = (Get-WmiObject -Class Win32_ComputerSystem).SystemType -match "(x64)"
if ($is64bit) {
Start-Process powershell -Verb runAs ". {reg import $env:USERPROFILE\Downloads\chrome_update_remove.reg /reg:64}" -PassThru | Out-Null
Start-Sleep 1;
del ".\chrome_update_remove.reg";
} else {
Start-Process powershell -Verb runAs ". {reg import $env:USERPROFILE\Downloads\chrome_update_remove.reg /reg:32}" -PassThru | Out-Null
Start-Sleep 1;
del ".\chrome_update_remove.reg";
}
$version = $((Get-ItemProperty -Path "$(PSDrive | ?{$_.Name -eq "HKLM"}):\Software\WOW6432Node\Google\Update\Clients\*" | ?{$_.Name -eq "Google Chrome"}).pv);
Write-Host "Uninstalling Chrome version [ $($version) ]..";
try {
Start-Process "${env:ProgramFiles(x86)}\Google\Chrome\Application\${version}\Installer\setup.exe" -ArgumentList ("--uninstall","--system-level");
}
Catch { # on exception or error, alternative uninstall..
Write-Error "<<< Error on Uninstalling via setup directory, re-trying alternate uninstall. >>>";
Start-Process chrome.exe -ArgumentList @("--uninstall","--force-uninstall")
}
# Preload download options from external site.
$AllContent = Invoke-WebRequest -Uri "https://www.slimjet.com/chrome/google-chrome-old-version.php" -UseBasicParsing -Method Get
# Selection list numbered.
$r=0;
$AllContent.Links | ?{$_ -ilike "*.exe*"} | %{
$_ | Add-Member -Name Selection -Value $($r) -MemberType NoteProperty -Force;
$_.href = $_.href;
$_.tagName = ($_.tagName).toLower() -replace "<","" -replace ">","";
$_.outerHTML = $_.outerHTML -replace "[^0-9]+`.{1}[^0-9]+`.{1}[^0-9]+`.{1}[^0-9]+","" -replace "`'`>"," @ Version " -replace "</a>","";
$r++;
}
Write-Host -Foreground Red -Background Yellow "[ Content gathered from slimjet.com ] - LIST OF CHROME DOWNLOADS";
$dload = $AllContent.Links | ?{$_ -ilike "*.exe*"}
$dload | Format-Table -AutoSize
$sel = Read-Host -Prompt "Please make your selection from the list above: ";
[int]$sel = ($sel -as [int]);
$finurl = ($($dload[$sel]).href -split "=")[1] -replace "%2F","`/";
$execload = ($(($dload[($sel)]).href) -split "%2F")[1];
$selUrl = "https://www.slimjet.com/chrome/$($finurl)";
# Download chrome, downgrade pack..
Start-Job -ScriptBlock {
Start-Process -FilePath "msedge.exe" -ArgumentList @($using:selUrl,"--/prefetch:5") -Wait -ErrorAction SilentlyContinue;
} | Get-Job | Wait-Job -Any | Receive-Job;
# Install chrome downgrade pack..
Start-Job -ScriptBlock {
$latestfile = (Get-ChildItem -Path "$env:USERPROFILE\Downloads\" -Filter "*.exe" | Sort LastWriteTime -descending | Select -First 1).Name
if ($latestfile -ne "${using:execload}") { ren $latestfile "${using:execload}" -ErrorAction SilentlyContinue }
Start-Process -FilePath "${env:USERPROFILE}\Downloads\$latestfile" -NoNewWindow -Wait -ErrorAction SilentlyContinue;
} | Get-Job | Wait-Job | Receive-Job;
Start-Job -ScriptBlock {
# Stop\Disable running services for Chrome Updater(s) - Total of 4 services.
$services = @("GoogleChromeElevationService","gupdate","gupdatem","gusvc");
$services | %{
Start-Process sc -Verb runAs -ArgumentList @("stop", "$($_)");
Start-Process sc -Verb runAs -ArgumentList @("config","$($_)","start=disabled");
}
} | Get-Job | Wait-Job | Receive-Job;
# Rename local updates folder
ren "${env:ProgramFiles(x86)}\Google\Update" "Update_OLD"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment