Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
install chrome from powershell
(new-object System.Net.WebClient).DownloadFile('http://dl.google.com/chrome/install/375.126/chrome_installer.exe', 'c:/temp/chrome.exe');. c:/temp/chrome.exe /silent /install;rm c:/temp -rec
@Knotz113

This comment has been minimized.

Copy link

@Knotz113 Knotz113 commented Dec 15, 2015

this is pretty slick. Not super keen on the internet dependency, but if the internet was available, this is a pretty cool like line of code here...

Knotz

@yeungs

This comment has been minimized.

Copy link

@yeungs yeungs commented Apr 1, 2016

this doesn't work. Shouldn't the "c:/temp/chrome.exe" be "c:\temp\chrome.exe"?

@yaxzone

This comment has been minimized.

Copy link

@yaxzone yaxzone commented Apr 18, 2016

With a few changes, this works, worked on Win2012 and Win2012R2. It can be used all in one line:

$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)
@yeungs

This comment has been minimized.

Copy link

@yeungs yeungs commented Apr 19, 2016

Cool @yaxzone. Your command works.

@scottt732

This comment has been minimized.

Copy link

@scottt732 scottt732 commented Apr 29, 2016

I love you guys almost as much as I hate Internet Explorer protected mode on Windows Server. That's a LOT

@crismael

This comment has been minimized.

Copy link

@crismael crismael commented Oct 14, 2016

Hats off to you guys! thanks for that script.

@gleb-svechnikov

This comment has been minimized.

Copy link

@gleb-svechnikov gleb-svechnikov commented Oct 31, 2016

@yaxzone thank you.

@Jorgemunive

This comment has been minimized.

Copy link

@Jorgemunive Jorgemunive commented Mar 16, 2017

@yaxzone works for windows server 2012

@xadamxk

This comment has been minimized.

Copy link

@xadamxk xadamxk commented Apr 15, 2017

I love you guys almost as much as I hate Internet Explorer protected mode on Windows Server. That's a LOT

LOL, thanks guys!

@nicolaigj

This comment has been minimized.

Copy link

@nicolaigj nicolaigj commented Apr 25, 2017

Thanks guys, found this quite useful for installing chrome on 30+ machines in Azure!

If I may, I would suggest some small changes to make it a bit simpler and more readable. Firstly I would use the Invoke-WebRequest cmdlet to download the file, instead of creating a web client object and then download it, and instead of a Do-Until-loop I would use Start-Process with the -Wait switch, it will wait until the installer is done and continue instead of checking it with a loop and then continue. Secondly it is good practice to use the full command names instead of aliases, it makes it easier to read and understand for a novice and remove the risk of an alias to be removed so that the script fails (https://daniel.haxx.se/blog/2016/08/19/removing-the-powershell-curl-alias/).

$Path = $env:TEMP; $Installer = "chrome_installer.exe"; Invoke-WebRequest "http://dl.google.com/chrome/install/375.126/chrome_installer.exe" -OutFile $Path\$Installer; Start-Process -FilePath $Path\$Installer -Args "/silent /install" -Verb RunAs -Wait; Remove-Item $Path\$Installer

Thanks again :)

@etemiz

This comment has been minimized.

Copy link

@etemiz etemiz commented Jun 20, 2017

this is neat

@zimmertr

This comment has been minimized.

Copy link

@zimmertr zimmertr commented Oct 10, 2017

Thanks @nicolaigj!

@noappleonhead

This comment has been minimized.

Copy link

@noappleonhead noappleonhead commented Oct 23, 2017

Big Thanks!!!

@Millian32

This comment has been minimized.

Copy link

@Millian32 Millian32 commented Dec 7, 2017

nice script, thanks a lot! Helped me on Azure as well!!

@tenhow

This comment has been minimized.

Copy link

@tenhow tenhow commented Dec 11, 2017

nice script ,help me on server 1709!

@tylerschloesser

This comment has been minimized.

Copy link

@tylerschloesser tylerschloesser commented Dec 29, 2017

fabulous. was pulling my hair out trying to use ie11 on my aws EC2 instance XD

@cool2venki

This comment has been minimized.

Copy link

@cool2venki cool2venki commented Jan 27, 2018

neat thanks..

@shaikhakhtar

This comment has been minimized.

Copy link

@shaikhakhtar shaikhakhtar commented Feb 6, 2018

Thanks @yaxzone for your script. It worked very well...!!

@ahmadmarafa

This comment has been minimized.

Copy link

@ahmadmarafa ahmadmarafa commented Feb 28, 2018

Thaaaank youuu

@simonherbert

This comment has been minimized.

Copy link

@simonherbert simonherbert commented Apr 28, 2018

Thanks @nicolaigj !
It works on Windows Server 2008 R2, 2012, 2012 R2, and 2016.
Way better than trying to use IE to download Chrome.

@ChristianOtte

This comment has been minimized.

Copy link

@ChristianOtte ChristianOtte commented Jun 1, 2018

This is awesome! Helps the deployment day on 30+ servers
@nicolaigj - you really made the script nice and readable in true powershell fasion

@rcaljouw

This comment has been minimized.

Copy link

@rcaljouw rcaljouw commented Jun 28, 2018

Nice!

Thanks both @yaxzone and @nicolaigj

@foxx

This comment has been minimized.

Copy link

@foxx foxx commented Jul 23, 2018

Why are you not using https? Why are you not using latest?

https://dl.google.com/chrome/install/latest/chrome_installer.exe

@Larswa

This comment has been minimized.

Copy link

@Larswa Larswa commented Aug 10, 2018

@XuTenghao Can you start up Chrome on the Windows server 1709? I use as a buildserver and wanted to run Selenium tests, but the chrome.exe fails with a pretty generic "ERROR:main_dll_loader_win.cc(134)] Failed to load Chrome DLL" Are you getting that, or can you log on to the server and do a chrome.exe --headless ?

@Connor14

This comment has been minimized.

Copy link

@Connor14 Connor14 commented Aug 16, 2018

@Larswa I had the same problem.

@redramos

This comment has been minimized.

Copy link

@redramos redramos commented Oct 5, 2018

You can use this:

$Path = $env:TEMP; $Installer = "chrome_installer.exe"; Invoke-WebRequest "https://dl.google.com/chrome/install/latest/chrome_installer.exe" -OutFile $Path$Installer; Start-Process -FilePath $Path$Installer -Args "/silent /install" -Verb RunAs -Wait; Remove-Item $Path$Installer

@Penta-admin

This comment has been minimized.

Copy link

@Penta-admin Penta-admin commented Oct 10, 2018

after installing ,how we can bring up chrome in server 1709

@Hugo22O

This comment has been minimized.

Copy link

@Hugo22O Hugo22O commented Dec 26, 2018

after installing ,how we can bring up chrome in server 1709

It should be on your desktop.

@eesheesh

This comment has been minimized.

Copy link

@eesheesh eesheesh commented Feb 8, 2019

Here's a version of @redramos's command that can work from the Run dialog (considering its length limits):
PowerShell -Command "& {$P = $env:TEMP + '\chrome_installer.exe'; Invoke-WebRequest 'https://dl.google.com/chrome/install/latest/chrome_installer.exe' -OutFile $P; Start-Process -FilePath $P -Args '/silent /install' -Verb RunAs -Wait; Remove-Item $P}"

@o-l-a-v

This comment has been minimized.

Copy link

@o-l-a-v o-l-a-v commented Oct 9, 2019

Neat commands y'all. But it installs 32 bit Chrome on 64 bit Windows. Anyone found a always latest version URL for Chrome 64 bit?

@STiG-1

This comment has been minimized.

Copy link

@STiG-1 STiG-1 commented Nov 10, 2019

Neat commands y'all. But it installs 32 bit Chrome on 64 bit Windows. Anyone found a always latest version URL for Chrome 64 bit?

@o-l-a-v Using this code, it downloads the online installer, and the 64-bit version is downloaded and installed:
$uri = "https://dl.google.com/chrome/install/latest/chrome_installer.exe" $path = "$PSScriptRoot\ChromeSetup.exe" Invoke-WebRequest -Uri $uri -OutFile $path Start-Process $path /install -NoNewWindow -Wait Remove-Item .\ChromeSetup.exe

@o-l-a-v

This comment has been minimized.

Copy link

@o-l-a-v o-l-a-v commented Nov 11, 2019

@STiG-1
Yeah, I've found that url too. It installs x86 which will get upgraded to x64 later on of the OS is actually x64.

@goprojojo

This comment has been minimized.

Copy link

@goprojojo goprojojo commented Nov 21, 2019

I don't have access to internet on my windows server. How can I use this script then?

@jrudley

This comment has been minimized.

Copy link

@jrudley jrudley commented Dec 2, 2019

I don't have access to internet on my windows server. How can I use this script then?

You need to download the offline installer for Chrome. Store it on some internal file share and copy down during install or add it into the image, etc

@lachlann562

This comment has been minimized.

Copy link

@lachlann562 lachlann562 commented Apr 24, 2020

For something a little more sophisticated, here is a powershell function you can run. it also uses the latest version, not a specific version. i also used -PassThru to get the explicit process i started.

function Install-Chrome
{
    $LocalTempDir = $env:TEMP; 
    $ChromeInstaller = "ChromeInstaller.exe"; 
    $url='http://dl.google.com/chrome/install/latest/chrome_installer.exe'; 
    $output="$LocalTempDir\$ChromeInstaller"

    try {
        (new-object    System.Net.WebClient).DownloadFile($url, $output); 
        $p = Start-Process $output -ArgumentList "/silent","/install" -PassThru -Verb runas; 

        while (!$p.HasExited) { Start-Sleep -Seconds 1 }

        Write-Output ([PSCustomObject]@{Success=$p.ExitCode -eq 0;Process=$p})
    } catch {
        Write-Output ([PSCustomObject]@{Success=$false;Process=$p;ErrorMessage=$_.Exception.Message;ErrorRecord=$_})
    } finally {
        Remove-Item "$LocalTempDir\$ChromeInstaller" -ErrorAction SilentlyContinue -Verbose
    }

}

Install-Chrome
@prc1234

This comment has been minimized.

Copy link

@prc1234 prc1234 commented May 26, 2020

thank you so much. This solution works like a charm. Is there a way by which i can extract the chrome version from "http://dl.google.com/chrome/install/latest/chrome_installer.exe"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.