diff --git a/Install Chrome in Windows Powershell b/Install Chrome in Windows Powershell index 509bc24..c5112c5 100644 --- a/Install Chrome in Windows Powershell +++ b/Install Chrome in Windows Powershell @@ -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) \ No newline at end of file +# 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 +} \ No newline at end of file