SEARCH

How-To Geek

How to Auto-Update Your System Utilities or Web Files with a Script

image

One of the great things about most system utilities is their portability. Many simply are distributed directly as an exe or in a zip file and are ready to use with no install required. Because of the simplicity of use, these types of applications are easily updated, however many lack any form of auto-update capability. Our UpdateFromWeb script solves this problem as it makes installing updates to portable applications, or any file available via the web for that matter, an automated process.

Usage

The UpdateFromWeb script usage is pretty simple and we have provided several examples below. You simply provide the source URL and the directory where the files to be updated on your computer are located and the script does the rest.

Features include:

  • Universal – works for any tools or files on any URL
  • Directory scanning for updating all applicable files in a local directory (including subdirectories)
  • Automatic unzipping and extraction
  • Direct URL downloads for single file updates
  • Case conversion for websites where URLs are case sensitive
  • New file detection for only updating newer versions
  • Automatic shutdown and restart of running applications which need to be updated
  • Can be run on demand or automated

There are more features included which are documented in the script file. Just open it in Notepad (or any other text editor) to view all the options.

The UpdateFromWeb script makes use of a couple of external tools which will need to be on your system prior to use. The download links for these tools are provided below and need to be placed in a folder in your system’s PATH variable (if in doubt, just put these required files in C:\Windows).

Not Just for Tools or Applications

As mentioned above, the UpdateFromWeb script can be used for any file which has a consistent URL. For example, if a project is updated nightly using the URL mysite.com/project.zip, you can use the UpdateFromWeb script to automatically download and extract the zip file to a local folder on your machine.

On a similar note, you can use the script to keep files and/or tools consistent across multiple machines. Just upload a file to a central location and an automated process running UpdateFromWeb can handle the rest.

Examples

The UpdateFromWeb script can be both used from the command line or hardcoded. Additionally, you can mix and match as needed.

Below are some examples which demonstrate the usage as well as the respective execution settings for both the command line and hardcode.

Update all SysInternals tools located in “C:\My Tools” and restart any running applications which were updated:

Command line:

UpdateFromWeb /U:http://live.sysinternals.com/tools /D /R “/T:C:\My Tools”

Hardcode:

SET URL=http://live.sysinternals.com/tools

SET TargetDir=C:\My Tools

SET UpdateDir=1

SET RestartStopped=1

 

Update all Nirsoft tools located in “C:\My Tools” and all subdirectories:

Command line:

UpdateFromWeb /U:http://www.nirsoft.net/utils /D /S /Z /L “/T:C:\My Tools”

Hardcode:

SET URL=http://www.nirsoft.net/utils

SET TargetDir=C:\My Tools

SET UpdateDir=1

SET Recurse=1

SET ToLower=1

SET Unzip=1

SET RestartStopped=1

 

Update the file named “Specs.doc” from mysite.com and copy it to “C:\Files\Latest Specs.pdf”:

Command line:

UpdateFromWeb /U:http://mysite.com/Specs.pdf “/F:Latest Specs.pdf” /T:C:\Files

Hardcode:

SET URL=http://mysite.com/Specs.pdf

SET TargetDir=C:\Files

SET FileToGet=Latest Specs.pdf

 

Update the files in the “C:\Files” directory with latest files from Specs.zip on mysite.com:

Command line:

UpdateFromWeb /U:http://mysite.com/Specs.zip /D /N /Z /T:C:\Files

Hardcode:

SET URL=http://mysite.com/Specs.zip

SET TargetDir=C:\Files

SET UpdateDir=1

SET CopyNewFiles=1

SET Unzip=1

 

Update all files in the “C:\Files” to be in sync with the files stored on mysite.com/files:

Command line:

UpdateFromWeb /U:http://mysite.com/files” /D /T:C:\Files

Hardcode:

SET URL=http://mysite.com/files

SET TargetDir=C:\Files

SET UpdateDir=1

 

 

Download Update From Web Script

Download Download.exe Tool

Download 7-Zip Command Line Tool

Jason Faulkner is a developer and IT professional who never has a hot cup of coffee far away. Interact with him on Google+

  • Published 01/12/12

Comments (8)

  1. Bruno Casarini

    WSCC (http://www.kls-soft.com/wscc/index.php) already does that.

  2. Jason Faulkner

    @Bruno Casarini – Actually no. WSCC only works on Sysinternals and Nirsoft, can’t be automated, doesn’t do shutdown/restart, etc.
    This script works on _any_ site and isn’t limited to just those two.

  3. Howard

    did not like SET TargetDir=”C:\Program Files (x86)\Nirsoft\NirSoft”

    the FILES was interpreted as a possible command although it came up as invalid parameter … maybe because of the spaces at both ends.

    had to use short PROGRA~2 for the script to work

    would like to know how the nirsoft FTP handes the 64 versus the 32 bit versions also … I use the nirlauncher method of appending -x64 to the end of the EXE’s

  4. Jason Faulkner

    @Howard – If you are hard coding the parameters into the script, _do not_ put the path in quotes.

    As for the 64-bit variations, the directory scanning function can only match filenames which exist on your system. So in the event there is a different download file for a 64-bit variant (i.e. tool.exe is deployed on your system yet it is distributed via URL in tool-64.zip), you would have to use the direct URL download function for that particular tool.

    Unfortunately, the Nirsoft panel doesn’t even make the 64-bit versions available, probably because the file names of both the 32-bit and 64-bit are the same.

  5. Doh

    wget or rsync for the win!

  6. SatoMew

    @Howard, don’t use absolute paths, they tend to cause those sort of issues. Instead of “[Drive letter]:\Program Files (x86)\Nirsoft\NirSoft” use “%ProgramFiles(x86)%\Nirsoft\NirSoft” (and without the quotes, obviously).

  7. Jason Faulkner

    @Doh – While wget is fully featured, it is quite messy on Windows (requires ~5 DLLs, creates empty local files for non-existing remote files, etc.) and overkill for what this script needs to do.

  8. Jason Faulkner

    @SatoMew – While you can use environment variables for paths, the batch processor will expand the variable to the respective path so, in this case, it is essentially the same as hard coding the full path.

    In the case of @Howard’s issue, he was hard coding the path into the script file and placing the target path in quotes. If you go the route of hard coding into the script directly, you should not put the path in quotes in the SET command.

Get Free Articles in Your Inbox!

Join 134,000 newsletter readers

Email:

Go check your email!