Update Install Chrome in Windows Powershell

This commit is contained in:
billy 2026-02-07 01:38:45 +02:00
parent dcb08d9a72
commit e6b4318262
1 changed files with 31 additions and 1 deletions

View File

@ -1 +1,31 @@
$LocalTempDir = $env:TEMP; $ChromeInstaller = "ChromeInstaller.exe"; (new-object System.Net.WebClient).DownloadFile('http://dl.google.com/chrome/install/375.126/chrome_installer.exe', "$LocalTempDir\$ChromeInstaller"); & "$LocalTempDir\$ChromeInstaller" /silent /install; $Process2Monitor = "ChromeInstaller"; Do { $ProcessesFound = Get-Process | ?{$Process2Monitor -contains $_.Name} | Select-Object -ExpandProperty Name; If ($ProcessesFound) { "Still running: $($ProcessesFound -join ', ')" | Write-Host; Start-Sleep -Seconds 2 } else { rm "$LocalTempDir\$ChromeInstaller" -ErrorAction SilentlyContinue -Verbose } } Until (!$ProcessesFound)
# Script to install the latest version of Google Chrome
# Check if the script is running with administrator privileges
if (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Write-Warning "Please run this script as Administrator!"
Break
}
# URL for the latest Chrome installer
$chromeUrl = "https://dl.google.com/chrome/install/latest/chrome_installer.exe"
$installerPath = "$env:TEMP\chrome_installer.exe"
Write-Host "Downloading Google Chrome..." -ForegroundColor Green
try {
# Download the installer
Invoke-WebRequest -Uri $chromeUrl -OutFile $installerPath -UseBasicParsing
Write-Host "Installing Google Chrome..." -ForegroundColor Green
# Install silently without user interaction
Start-Process -FilePath $installerPath -Args "/silent /install" -Wait
Write-Host "Google Chrome has been successfully installed!" -ForegroundColor Green
# Delete the installer file
Remove-Item $installerPath -Force
} catch {
Write-Host "Error during installation: $_" -ForegroundColor Red
}