PoshCode Archive  Artifact [0f519aa17b]

Artifact 0f519aa17bd3d53df86af9a8af79d8c847e85eff8c333ba9c515545d537fae17:

  • File Google-Chromium-Download.ps1 — part of check-in [5e3860c614] at 2018-06-10 13:09:59 on branch trunk — Download and install Google Chromium if there is a newer version available. (user: MJWJ1 size: 2061)

# encoding: ascii
# api: powershell
# title: Google Chromium Download
# description: Download and install Google Chromium if there is a newer version available.
# version: 0.1
# type: script
# author: MJWJ1
# license: CC0
# x-poshcode-id: 2422
# x-archived: 2013-09-28T02:21:43
# x-published: 2013-12-26T20:39:00
#
#
<#
    .Synopsis
        Download Google Chromium if there is a later build.
    .Description
        Download Google Chromium if there is a later build.        
#>

Set-StrictMode -Version Latest
Import-Module bitstransfer

# comment out when not debugging
$VerbosePreference = "Continue"
#$VerbosePreference = "SilentlyContinue"

$versionFile = "$Env:temp\latestChromiumVersion.txt"
$installedChromiumVersion = 0

trap [Exception] { 
      write-host
      write-error $("TRAPPED: " + $_.Exception.GetType().FullName); 
      write-error $("TRAPPED: " + $_.Exception.Message); 
      [string]($installedChromiumVersion) > $versionFile
      exit; 
}


if (Test-Path $versionFile)
{ $installedChromiumVersion = [int32] (cat $versionFile) }

$latestChromiumBuildURL ="http://build.chromium.org/f/chromium/snapshots/chromium-rel-xp"
Start-BitsTransfer "$latestChromiumBuildURL/LATEST" $versionFile
$latestChromiumVersion = [int32] (cat $versionFile)

if ($installedChromiumVersion -eq $latestChromiumVersion)
{ 
    Write-Verbose "Exiting... Version $installedChromiumVersion is the latest."
    return
}

$installerAppName = "mini_installer"
$installer = "$Env:temp\$installerAppName.exe"
Write-Verbose "Initiating download of new version $latestChromiumVersion"
Start-BitsTransfer "$latestChromiumBuildURL/$latestChromiumVersion/mini_installer.exe" $installer
Write-Verbose "Installing new version of Chromium"
Invoke-Item $installer
$installerRunning = 1
while (!($installerRunning -eq $null))
{ 
    sleep 5
    $installerRunning = ( Get-Process | ? {$_.ProcessName -match "$installerAppName"} )
}

Write-Verbose "New Chromium Installed! Please restart the Chromium browser"