This is an old revision of the document!
PowerShell script for checking HippoEDIT version
- hippo_version_checker.ps1
<# The script compares installed HippoEDIT version with the latest published on HippoEDIT web site. If installed version is older, the information is written into Windows Log and a small information popup appears. TODO: - add a check box, do not remind about this version #> Clear-Host # Installed version $version_installed = "0.0.0" $xmlsettingsfilename = "$env:AppData\HippoEDIT\hippoedit.config" $xmlsettings = Get-Content -LiteralPath $xmlsettingsfilename $pattern_wholeline = "\<GENERAL\s{1,}ver\=`"(\d{1,}\.\d{1,}\.\d{1,})`"" $pattern_version = "`"(\d{1,}\.\d{1,}\.\d{1,})`"" $textmatches = $xmlsettings -match $pattern_wholeline if ($textmatches.count -ge 1) { if ($textmatches[0] -match $pattern_version){ $version_installed = $matches[1] } } #$xmlsettings = New-Object -TypeName XML #$xmlsettings.Load("$env:AppData\HippoEDIT\hippoedit.config") #$version_installed = $xmlsettings.XMLConfigSettings.GENERAL.ver # Internet version $url = "http://direct.hippoedit.com/api/get_repository.php" $web_client = New-Object System.Net.WebClient $web_contents = $web_client.DownloadString($url) $xml_web_contents = [xml]$web_contents $version_published = $xml_web_contents.repository.core.release.version # Comparison and dumping in windows log # Creating of the log is only necessary once on the same PC, so the command "New-EventLog" can be commented after initial run # For proper operation of the script following command shall be once executed New-EventLog -LogName Application -Source "HippoEDIT admin scripts" -ErrorAction SilentlyContinue if($version_installed -ne $version_published){ Write-EventLog ` -LogName Application ` -Source 'HippoEDIT admin scripts' ` -EntryType Warning ` -EventId 27002 ` -Message "HippoEDIT installed version [$version_installed] older then published [$version_published]. You need to install new version." Add-Type -AssemblyName System.Windows.Forms $Form = New-Object system.Windows.Forms.Form $Form.Text = "HippoEDIT need to be updated" $Form.TopMost = $true $Form.Width = 280 $Form.Height = 100 $lblName = New-Object system.windows.Forms.Label $lblName.Text = "Installed version: $version_installed" $lblName.AutoSize = $true $lblName.Width = 260 $lblName.Height = 10 $lblName.location = new-object system.drawing.point(20,20) $lblName.Font = "Courier New,9" $Form.controls.Add($lblName) $lblName = New-Object system.windows.Forms.Label $lblName.Text = "Published version: $version_published" $lblName.AutoSize = $true $lblName.Width = 260 $lblName.Height = 10 $lblName.location = new-object system.drawing.point(20,40) $lblName.Font = "Courier New,9" $Form.controls.Add($lblName) [void]$Form.ShowDialog() } else { Write-EventLog ` -LogName Application ` -Source 'HippoEDIT admin scripts' ` -EntryType Information ` -EventId 27001 ` -Message "HippoEDIT installed version [$version_installed] is up to date." }