Scripting, Sysinternals
comments 3

Sysinternals: Auto update script for sysinternals tools

I have written it many times but I like to say it again and again. I am a Sysinternals fan. I use their tools quite often, if not everyday. Sysinternals team releases updates to these tools often. These updates are either bug fixes or somtimes new features / tools. There are multiple ways to know about these updates

  • Subscribe to sysinternals blog RSS feed and download the update manually
  • Visit sysinternals website regurarly and get the updates when ever available
  • Or many other ways….

I am not used to any RSS aggregators or readers. Even if I use one, I still have to manually download the update. It is the same case with visting their website. I wanted to write something to automatically update my sysinternals tools folder as and when there is an update. Again, there are multiple ways to achieve that. I could have written a RSS listener service which will look for updates in the Sysinternals feed and download the updates once they are available.  But that is too complex for a simple task like downloading files from a website.

My method to achieve this is quite simple. I use XMLHTTPREUEST object and depend on the Last-Modified information in the http header. If you have observed closely, all Sysinternals download links are very uniform. For example, to download Disk2VHD, you need to access http://download.sysinternals.com/Files/Disk2vhd.zip. For all other tools, you just need to replace Disk2VHD with the respective tool name. So, constructing a URL is that simple.

PSTools are the only exception. They are all packaged under pstools.zip. Okay, this URL funda will work until someone at Sysinternals thinks about changing it and I hope they don’t.

Where is this tool?
Sysinternals-AutoUpdater [download id=”13″ format=”4″]

What is this tool?
This tool is a simple VBScript. I will release the PowerShell version too. I have tested this on Windows 7 only. I did not test it on any earlier version of Windows but I don’t see a reason for this to fail on Vista or XP.

how to use it?
Another requirement to run this script is 7Zip. This is required for extracting files from the downloaded ZIP archive. 7Zip is a free tool and you can download it from http://www.7-zip.org

You can modify the location of 7Zip by changing the following line in the script

str7ZipLocation = “C:\Program Files\7-Zip\7z.exe”

A very important file in this framework is the Sysinternals-AutoUpdate.XML. This has a list of all tools, their download URLs and last-modified time as found in the http header. As shown here, Modified tag is set to null. So, when you run this script, it will download all sysinternals tools and then update the Last-Modified time for each tool.

Sysinternals-AutoUpdate.xml

Sysinternals-AutoUpdate.xml

If Sysinternals team releases a new tool, all you need to do is just enter that information in the same format as shown above. It will be downloaded automatically next time this script runs.

Once you have all this setup, you just need to run

cscript SysInternals-AutoUpdate.vbs /dest:c:\sysinternals

/dest command-line argument can be any folder to which you have write access to. All the downloaded ZIP files will be extracted to this location.

All the log statements will be written to Sysinternals-Autoupdate.log. This log will be very comprehensive. By default, the log file will be created at the same location as the script file. If you want to change the location, you can put the absolute path to the log file location by changing the following line in the script

strLogName = “SysInternals-AutoUpdate.log”

I have scheduled this to run at 8AM every morning. This way, if there were any updates to the tools overnight, I will have all of them downloaded by the time I wake up. Nice..isn’t it.

Do let me know your thoughts on this.

Filed under: Scripting, Sysinternals

by

Ravikanth is a principal engineer and the lead architect for Microsoft and VMware virtualized and hybrid cloud solutions within the Infrastructure Solutions Group at Dell EMC. He is a multi-year recipient of Microsoft Most Valuable Professional (MVP) award in Windows PowerShell (CDM) and Microsoft Azure. Ravikanth is the author of Windows PowerShell Desired State Configuration Revealed (Apress) and leads Bangalore PowerShell and Bangalore IT Pro user groups. He can be seen speaking regularly at local user group events and conferences in India and abroad.