In dealing with the upcoming Daylight Savings Time changes, Java is one of the things that needs to be updated. Sun has released a tool that updates the Java instances installed on a system with the new DST information. The problem is that Java doesn’t ever uninstall itself when it upgrades, and some applications might have embedded Java.

On my system with a Vista Ultimate clean install that’s about a month old, here’s what a search for Java finds:

C:Usersjtdennis>dir c: /s /b | find “java.exe”
c:Program FilesJavajre1.5.0_11binjava.exe
c:Program FilesJavajre1.6.0binjava.exe
c:WindowsSystem32java.exe

That’s for a relatively clean system Since I’m responsible for multiple computers, it’s easy to see how much trouble it can be to install the update on every version of Java installed on Windows installs that are older. I have come up with a couple scripts that will find every copy of Java on a system and run Sun’s updater program against each one. Add it to a login script and the updating is much, much easier. I’m sure the scripts could be combined into a single one, but I have limited VBScripting abilities and not a lot of time available to work on it.

The script needs to be run as an Administrator, and in Vista it needs to run elevated.

Here are the scripts:

dstjava.cmd

@echo off
::if c:javadst.txt exists, don’t try and upgrade again.
if exist c:javadst.txt goto javaend
::find all java locations and save to a text file
dir c: /s /b | find “java.exe”>%temp%java.txt
::run the upgrade with the text file as input
cscript \serverscriptdirdstjava.vbs %temp%java.txt
::save text file to prevent future upgrades.
echo “java updated for DST changes.”>c:javadst.txt
:javaend

dstjava.vbs:

Set objArgs = WScript.Arguments
Const ForReading = 1
Set objDictionary = CreateObject(“Scripting.Dictionary”)
Set objFSO = CreateObject(“Scripting.FileSystemObject”)
Set objTextFile = objFSO.OpenTextFile(objArgs(0), ForReading)

i = 0
Do While objTextFile.AtEndOfStream <> True
strNextLine = objTextFile.Readline
objDictionary.Add i, strNextLine
i = i + 1
Loop
For Each objItem in objDictionary
strExe = objDictionary.Item(objItem)
Set wshShell = WScript.CreateObject (“WSCript.shell”)
wshShell.run “””” & strExe & “””” & ” -jar ” & “\serverscriptdirtztzupdater.jar” & ” -u”
wshShell.run “””” & strExe & “””” & ” -jar ” & “\serverscriptdirtztzupdater131.jar” & ” -u”
set wshshell = nothing
‘test to make sure executed command is correct
‘Wscript.Echo “””” & strExe & “””” & ” -jar ” & “\serverscriptdirtztzupdater.jar” & ” -u”
Next

[tags]java, dst, daylight savings time, scripts, windows[/tags]