Thursday, July 29, 2010

Script to Auto-Update Your Sysinternals Tools

Jason Faulkner posted a very cool Batch script to freshen your library of Sysinternals tools over at  It queries the\tools repository and downloads matching tools in your library.  If you haven't already checked it out, you should (click here).

Here's a version I've done in VBScript.  You can tweak it for your needs and even schedule it to run periodically to keep your tools up to date.

Const livetools = "\\\tools"
Const localtools = "c:\sysinternals"

Set objFSO = CreateObject("Scripting.FileSystemObject")

On Error Resume Next
wscript.echo "info: connecting to"
Set objLiveFolder = objFSO.GetFolder(livetools)
If err.Number <> 0 Then
wscript.echo "fail: unable to connect"
End If

If objFSO.FolderExists(localTools) = False Then
wscript.echo "fail: local folder not found"
End If

For each objFile in objLiveFolder.Files
fileName = objFile.Name
If objFSO.FileExists(localtools & "\" & fileName) Then
wscript.echo "info: updating file " & fileName & "..."
sourceFile = liveTools & "\" & fileName
targetFile = localTools & "\" & fileName
objFSO.CopyFile sourceFile, targetFile, True
End If

Set objFolder = Nothing
Set objFSO = Nothing

If I had more time I'd do this in KiXtart and Powershell, but I'll leave that to someone else.  Enjoy!

No comments:

Post a Comment