Sunday, March 7, 2010

Checking For Updates

There are quite a few free utilities, add-ins, plug-ins, etc. that are either ubiquitous or at least my own preference to have on all computers. Keeping track of updates was a royal pain. Sometimes I'd get so busy for so long I'd neglect checking for months.
I wanted a script that checks Internet sites for updates rather quickly. I figured PowerShell would give me the power to do it. I finally found the code from Alex Angelopoulos at
WindowsITPro, but I'm not sure anyone thought to use it the way I wanted.
I prefer to leave my PowerShell security at the default level, which is to disable scripts from running. I use an old-fashioned CMD script as a wrapper-script to write my script, lower security, run the script, and finally delete the script and raise security back up.
The script requires maintenance, but it sure beats the old haphazard way. I edit the version-levels for each product to keep them current. The script checks the host web-page, tries to look for a version string, and if it can't find it, it is assumed the version has either changed to a newer one, or the version can no longer be found.

Some web-pages confound all my efforts to find a version I can query. That's because they have some very intricate layers of web-sites working together that make them hard to hack. I'm not trying to hack them - just query them - but their security precautions have made it impossible for me to check Apple's or Adobe's sites. The others are pretty straight-forward.
As usual, watch out for text-wrapping in the code window.


:: Allow PS scripts to run
powershell -command "& {Set-ExecutionPolicy -Scope LocalMachine Unrestricted -Force}"

:: Create Powershell script (from Alex K. Angelopoulos, WindowsITPro)
:: http://windowsitpro.com/article/articleid/99844/use-the-net-webclient-class-in-powershell-scripts-to-access-web-data.html
@echo Param( > ".\Get-WebString.ps1"
@echo [string]$Uri, >> ".\Get-WebString.ps1"
@echo $Encoding = "Default" >> ".\Get-WebString.ps1"
@echo ) >> ".\Get-WebString.ps1"
@echo $WebClient = New-Object System.Net.WebClient >> ".\Get-WebString.ps1"
@echo $WebClient.Encoding = [System.Text.Encoding]::$Encoding >> ".\Get-WebString.ps1"
@echo $WebClient.DownloadString($Uri) >> ".\Get-WebString.ps1"

:Sun Java Update 18
powershell -command ".\Get-WebString.ps1 http://www.java.com/en/download/manual.jsp" | find /i "Version 6 Update 18"
if %errorlevel%==0 goto :Diskeeper
"C:\Program Files\Internet Explorer\IEXPLORE.EXE" http://www.java.com/en/download/manual.jsp

:Diskeeper
powershell -command ".\Get-WebString.ps1 http://www.diskeeper.com/Diskeeper/update-patch/update-patch.aspx" | find /i "Build-900"
if %errorlevel%==0 goto :Firefox
"C:\Program Files\Internet Explorer\IEXPLORE.EXE" http://www.diskeeper.com/Diskeeper/update-patch/update-patch.aspx

:Firefox
powershell -command ".\Get-WebString.ps1 http://www.mozilla.com/en-US/firefox/ie.html" | find /i "US/firefox/3.6"
if %errorlevel%==0 goto :doPDF
"C:\Program Files\Internet Explorer\IEXPLORE.EXE" http://www.mozilla.com/en-US/firefox/ie.html
:: http://wiki.mozilla-x86-64.com/Firefox:Download

:doPDF 7.1.330
powershell -command ".\Get-WebString.ps1 http://www.dopdf.com/" | find /i "7.1.330"
if %errorlevel%==0 goto :Paint.NET
"C:\Program Files\Internet Explorer\IEXPLORE.EXE" http://www.dopdf.com/

:Paint.NET v3.5.4
powershell -command ".\Get-WebString.ps1 http://www.getpaint.net/" | find /i "v3.5.4"
if %errorlevel%==0 goto :IZArc
"C:\Program Files\Internet Explorer\IEXPLORE.EXE" http://www.getpaint.net/

:IZArc
powershell -command ".\Get-WebString.ps1 http://www.izarc.org/download.html" | find /i "4.1"
if %errorlevel%==0 goto :CPU_Z
"C:\Program Files\Internet Explorer\IEXPLORE.EXE" http://www.izarc.org/download.html

:CPU_Z
powershell -command ".\Get-WebString.ps1 http://www.cpuid.com/cpuz.php" | find /i "Z 1.53"
if %errorlevel%==0 goto :burnaware_free
"C:\Program Files\Internet Explorer\IEXPLORE.EXE" http://www.cpuid.com/cpuz.php

:burnaware_free
powershell -command ".\Get-WebString.ps1 http://www.burnaware.com/downloads.html" | find /i "2.4.4"
if %errorlevel%==0 goto :DeepBurner
"C:\Program Files\Internet Explorer\IEXPLORE.EXE" http://www.burnaware.com/downloads.html

:DeepBurner
powershell -command ".\Get-WebString.ps1 http://www.deepburner.com/?r=download" | find /i "DeepBurner Free 1.9"
if %errorlevel%==0 goto :ImgBurn
"C:\Program Files\Internet Explorer\IEXPLORE.EXE" http://www.deepburner.com/?r=download

:: It's longer, but I'm truncating many sections. You can extrapolate from here.
:: So on to the ending...

:END
del /q ".\Get-WebString.ps1"

:: Raise PS security back up
powershell -command "& {Set-ExecutionPolicy -Scope LocalMachine Restricted -Force}"
powershell -command "& {Set-ExecutionPolicy -Scope CurrentUser Undefined -Force}"
powershell -command "& {Set-ExecutionPolicy -Scope Process Undefined -Force}"


Why not use VersionTracker? Because my company blocks that site, and because that site has too many items, and not all the items I want. My script is just-right for me. While it runs, I can be doing other things. By running it once a week, I stay current.

No comments:

Post a Comment