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

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

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

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

commented Apr 19, 2016

Cool @yaxzone. Your command works.

@scottt732

This comment has been minimized.

Copy link

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

commented Oct 14, 2016

Hats off to you guys! thanks for that script.

@gleb-svechnikov

This comment has been minimized.

Copy link

commented Oct 31, 2016

@yaxzone thank you.

@Jorgemunive

This comment has been minimized.

Copy link

commented Mar 16, 2017

@yaxzone works for windows server 2012

@xadamxk

This comment has been minimized.

Copy link

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

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

commented Jun 20, 2017

this is neat

@zimmertr

This comment has been minimized.

Copy link

commented Oct 10, 2017

Thanks @nicolaigj!

@noappleonhead

This comment has been minimized.

Copy link

commented Oct 23, 2017

Big Thanks!!!

@Millian32

This comment has been minimized.

Copy link

commented Dec 7, 2017

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

@tenhow

This comment has been minimized.

Copy link

commented Dec 11, 2017

nice script ,help me on server 1709!

@tylerschloesser

This comment has been minimized.

Copy link

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

commented Jan 27, 2018

neat thanks..

@shaikhakhtar

This comment has been minimized.

Copy link

commented Feb 6, 2018

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

@ahmadmarafa

This comment has been minimized.

Copy link

commented Feb 28, 2018

Thaaaank youuu

@simonherbert

This comment has been minimized.

Copy link

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

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

commented Jun 28, 2018

Nice!

Thanks both @yaxzone and @nicolaigj

@foxx

This comment has been minimized.

Copy link

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

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

commented Aug 16, 2018

@Larswa I had the same problem.

@redramos

This comment has been minimized.

Copy link

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

commented Oct 10, 2018

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

@Hugo22O

This comment has been minimized.

Copy link

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

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}"

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.