PoshCode Archive  Artifact [85f849d949]

Artifact 85f849d949c9a1caf0c1ea475c8601fb5799785e3f7b59e22179b86338d8eeb2:

  • File Google-Chromium-Download.ps1 — part of check-in [882d37f05c] at 2018-06-10 13:17:42 on branch trunk — Download and install Google Chromium if there is a newer version available. (user: MJWJ1 size: 2323)

# 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: 2959
# x-archived: 2013-09-28T00:34:08
# x-published: 2013-09-18T09:28:00
#
#
<#
    .Synopsis
        Download Google Chromium if there is a later build.
    .Description
        Download Google Chromium if there is a later build.        
        http://poshcode.org/2422
#>

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"
#$latestChromiumBuildURL ="http://build.chromium.org/f/chromium/snapshots/Win"
$latestChromiumBuildURL ="http://commondatastorage.googleapis.com/chromium-browser-snapshots/Win"
Start-BitsTransfer "$latestChromiumBuildURL/LAST_CHANGE" $versionFile
$latestChromiumVersion = [int32] (cat $versionFile)

if ($installedChromiumVersion -eq $latestChromiumVersion)
{ 
    Write-Verbose "Exiting... Version $installedChromiumVersion is the latest. (from $latestChromiumBuildURL/LAST_CHANGE)"
    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"