'How to download Chrome standalone executables using a script without getting broken files?

A couple of weeks ago I made a batch script, using curl, for downloading all Chrome executable files that I could find, for just in case Chrome gets messed up by an update.

Right after running the script, I didn't check to see if the executables are running fine, because I was assuming there wouldn't be a problem with them. So, after letting the script pile up Chrome versions, just a few days ago I got a big surprise when I tried installing an older version of Chrome. None of the files downloaded by the script worked. Each time I'd try running them, I'd get "unknown installer error".

enter image description here

This is the script:

@echo off
set date_and_time=#1_%date:~-10,2%-%date:~3,2%-%date:~-4,4%_%time:~0,2%.%time:~3,2%.%time:~6,2%.#2
md "%USERPROFILE%\Chrome_old_versions\"
set dirct="%USERPROFILE%\Chrome_old_versions\Chrome_%date:~-10,2%-%date:~3,2%-%date:~-4,4%_%time:~0,2%.%time:~3,2%.%time:~6,2%"
md "%dirct%"
cd "%dirct%"
curl --output-dir %dirct% https://dl.google.com/chrome/install/{ChromeStandaloneSetup64}.{exe} -o %date_and_time% 
curl --output-dir %dirct% https://dl.google.com/chrome/install/beta/{ChromeBetaStandaloneSetup64}.{exe} -o %date_and_time%
curl --output-dir %dirct% https://dl.google.com/chrome/install/dev/{ChromeDevStandaloneSetup64}.{exe} -o %date_and_time%
curl --output-dir %dirct% https://dl.google.com/chrome/install/{ChromeStandaloneSetup}.{exe} -o %date_and_time%
curl --output-dir %dirct% https://dl.google.com/chrome/install/beta/{ChromeBetaStandaloneSetup}.{exe} -o %date_and_time%
curl --output-dir %dirct% https://dl.google.com/chrome/install/dev/{ChromeDevStandaloneSetup}.{exe} -o %date_and_time%
curl --output-dir %dirct% https://dl.google.com/chrome/mac/beta/{googlechromebeta}.{dmg} -o %date_and_time%
curl --output-dir %dirct% https://dl.google.com/release2/q/canary/{googlechrome}.{dmg} -o %date_and_time%
curl --output-dir %dirct% https://dl.google.com/chrome/mac/dev/{googlechromedev}.{dmg} -o %date_and_time%

That got me curios about why isn't it working, so I accessed https://dl.google.com/chrome/install/ChromeStandaloneSetup64.exe in Chrome and that got me a perfectly working exe. The strange thing is both exes downloaded through Chrome and curl had the same sha 512 hash. As I was puzzled, I tried wget and a powershell script.

For wget, I tried:

wget https://dl.google.com/chrome/install/ChromeStandaloneSetup64.exe --no-check-certificate

, which got me again "unknown installer error".

Thanks to @John Seerden, I then used his powershell script, which downloaded a googlechromestandaloneenterprise64.msi working executable. Seeing this, I replaced googlechromestandaloneenterprise64.msi URL in his script with https://dl.google.com/chrome/install/ChromeStandaloneSetup64.exe, but still got that error.

$uri = "https://dl.google.com/chrome/install/googlechromestandaloneenterprise64.msi"

if (-not $PSScriptRoot) {
    $PSScriptRoot = Split-Path -Parent -Path $script:MyInvocation.MyCommand.Definition
}
$outFile = "$PSScriptRoot\googlechromestandaloneenterprise64.msi"

Start-BitsTransfer -Source $uri -Destination $outFile

Start-Process -FilePath $outFile -Args "/qn" -Wait

I even tried downloading https://dl.google.com/chrome/install/googlechromestandaloneenterprise64.msi using wget and curl, but still got the error.

After some googling, I got across this post, which states something about getting an untagged installer, which I think has been downloaded through a 3rd party program like curl or wget, which ended in prompting "unknown installer error".

After some more googling, I got to this post, but instead of using Charles, I used Chrome Dev Tools to get the curl request from the Network tab. This didn't work either, same error.

Is it there any way I could download perfectly fine running Chrome executables through a script or is it there any way to fix the broken executables? I would prefer to not resort to something like headless Chrome.



Solution 1:[1]

I used WinMerge for comparing these two standalone Chrome exes, version 86.0.4240.111 - 64 bits and 87.0.4280.66 - 64 bits, respectively ChromeStandaloneSetup64_28-10-2020_14.24.03_valid_Copy_old_version.exe (downloaded from https://dl.google.com/chrome/install/ChromeStandaloneSetup64.exe - broken exe aka missing the download URL tags within the exe) and ChromeStandaloneSetup64_valid_Copy_latest_version.exe (downloaded from https://www.google.com/chrome/?standalone=1&platform=win64 - valid exe aka exe that has the download URL tags within it).

As as a comparison, here's a tagged download URL:

https://dl.google.com/tag/s/appguid%3D%7B8A69D345-D564-463C-AFF1-A69D9E530F96%7D%26iid%3D%7B04A7785F-B8A2-B4AA-7A45-17861EB0DE70%7D%26lang%3Dro%26browser%3D4%26usagestats%3D1%26appname%3DGoogle%2520Chrome%26needsadmin%3Dprefers%26ap%3Dx64-stable-statsdef_1%26installdataindex%3Ddefaultbrowser/chrome/install/ChromeStandaloneSetup64.exe

and here is an untagged download URL:

https://dl.google.com/chrome/install/ChromeStandaloneSetup64.exe

While in WinMerge, I've searched for "&lang=ro&browser" in ChromeStandaloneSetup64_valid_Copy_latest_version.exe (the file to the right), then I went to Edit > Select Line Difference (F4), then to Merge > Copy to Left. Next, I went to File > Save As > Save Left As...

enter image description here

I then ran the resulting exe (patched exe, having version 86.0.4240.111 64 bits) in a fresh Windows 7 virtual machine (VM), and this time it installed correctly. For testing purposes, I turned off the network, and, when going to the 3 dotted menu in Chrome > Help > About Chrome, indeed, Chrome was the old version. After that, I turned on network and it had been updating to the latest version, 87.0.4280.66 64 bits, running with no problems.

Even though ChromeStandaloneSetup64_valid_Copy_latest_version.exe (valid exe) came with a Zone Identifier Alternate Data Stream (ADS), unlike the broken exe, the resulting exe coming out the broken exe, lacking ADS, it ran perfectly fine in the VM. Regarding ADS, I downloaded the same valid Chrome exe twice (87.0.4280.66 64 bits) and I noticed the ADS had the same exact value.

enter image description here

I also did additional tests and I've noticed if the resulting exe is lacking the appguid and iid fields, it won't install.

Another thing I did, it was messing around with the values in the respective fields, so I made the appguid and iid fields look like this:

appguid={00000000-0000-0000-0000-000000000000}&iid={00000000-0000-0000-0000-000000000000}

, which turned out to make the executable not install, getting Error code: 0x80070057.

Once I was done messing around with the exes editing, I started messing with the URL.

As for this given URL, coming from https://www.google.com/chrome/?standalone=1&platform=win64 (valid exe):

https://dl.google.com/tag/s/appguid%3D%7B8A69D345-D564-463C-AFF1-A69D9E530F96%7D%26iid%3D%7B04A7785F-B8A2-B4AA-7A45-17861EB0DE70%7D%26lang%3Dro%26browser%3D4%26usagestats%3D1%26appname%3DGoogle%2520Chrome%26needsadmin%3Dprefers%26ap%3Dx64-stable-statsdef_1%26installdataindex%3Ddefaultbrowser/chrome/install/ChromeStandaloneSetup64.exe

I trimmed down the appguid and iid, getting:

https://dl.google.com/tag/s/lang%3Dro%26browser%3D4%26usagestats%3D1%26appname%3DGoogle%2520Chrome%26needsadmin%3Dprefers%26ap%3Dx64-stable-statsdef_1%26installdataindex%3Ddefaultbrowser/chrome/install/ChromeStandaloneSetup64.exe

, which led to a broken exe, getting the same error code as above, Error code: 0x80070057.

Next thing I did was going to https://codebeautify.org/generate-random-data-from-regexp and generating a random appguid and iid (using hexadecimal values, because that's what I noticed it was being used in those fields) using this pattern:

[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}

, then using two different numbers:

038C42B4-AF87-AD38-990A-4384A7E29E04 - for appguid

EC7C4A9D-76CB-FBA7-D1C2-70EB689DA8F4 - for iid

, I got this link:

https://dl.google.com/tag/s/appguid%3D%7B038C42B4-AF87-AD38-990A-4384A7E29E04%7D%26iid%3D%7BEC7C4A9D-76CB-FBA7-D1C2-70EB689DA8F4%7D%26lang%3Dro%26browser%3D4%26usagestats%3D1%26appname%3DGoogle%2520Chrome%26needsadmin%3Dprefers%26ap%3Dx64-stable-statsdef_1%26installdataindex%3Ddefaultbrowser/chrome/install/ChromeStandaloneSetup64.exe

, which, during installation, got me "Unable to connect to the Internet. If you use a firewall, please whitelist GoogleUpdate.exe" error.

enter image description here

So, since the appguid and iid were coming from a later version of Chrome (appguid and iid taken from 87.0.4280.66 and inserted into 86.0.4240.111), I assume, installation will finish successfully only if the appguid and iid contained in the exe itself, through computation during instalation, will yield a result that matches a value stored somewhere in the exe, or a value that also gets computed during installation. I say this, because when I installed the resulting valid standalone Chrome exe coming from the broken exe, the network was turned off, and there was no prior installation of Chrome on that system. Or maybe those two values are somehow tied to the operating system.

I conclusion, I think I'll end up modifing the URLs in the batch file with those appguid and iid, unless I decide to take a closer look at the URLs of the upcoming releases of Chrome to get an even better idea of how all of this is working.

These:

8A69D345-D564-463C-AFF1-A69D9E530F96 - for appguid

04A7785F-B8A2-B4AA-7A45-17861EB0DE70 - for iid

Solution 2:[2]

$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

Once the process is completed, you will see ‘Google Chrome’ icon on your Desktop. Click and run it

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2