• Home
  • About me

A little work blog

Windows software installation, packaging & distribution

Feeds:
Posts
Comments

VBScript get java version

March 30, 2009 by leereid

The java version installed on a PC can be determined by typing

java -version

on a command prompt, but this information is difficult to access through VBScript. I recently put together an installation that put java files into the java version currently installed. This meant finding out which one was the current version, so I put together the following VBScript to compare the version of java.exe in system32 with all java.exe files inside C:\Program Files\Java

Set oShell = CreateObject(“WScript.Shell”)
Set oFSO = CreateObject(“Scripting.FileSystemObject”)
sFile = oShell.ExpandEnvironmentStrings(“%systemroot%”) & “\system32\java.exe”
version = oFSO.GetFileVersion(sFile)
PFDir = oShell.ExpandEnvironmentStrings(“%programfiles%”)
javaDir = PFDIR & “\Java”
Set oFolder = oFSO.GetFolder(javaDir)
Set colFolders = oFolder.SubFolders
For Each folder In colFolders
 thisver = oFSO.GetFileVersion(folder & “\bin\java.exe”)
 If thisver = version Then
  JavaVersion= folder & “\”
 End If
Next

As I was doing this inside a custom action in an msi, I changed the variable JavaVersion to Session.TargetPath(“INSTALLDIR”)

Posted in VBScript, Vista, Work, XP, msi | No Comments Yet

  • Recent Posts

    • Inno Setup unpack
    • Installing Remote Server Administration Tools (RSAT) for Vista and Windows 7
    • ActiveSetup – your nemesis?
    • SCCM exclude members from a collection
  • Top Posts

    • VBScript Current Directory (or Folder)
    • Sweet VBScript - command line parameters
    • VBScript edit line in file
  • Tags

    ActiveSetup backup BDD code command line deployment dll edit error exit explorer file IE7 ie 7 install installs internet explorer internet explorer 7 logon msi parameter printing registry rename robocopy runas SAP SAPGUI Silent SMS startup switch uninstall uninstalls upgrade users VBScript Vista windows WindowsInstaller winxp wise wisepatch wisepath wisesetprofilesfolder

Blog at WordPress.com.

Theme: Mistylook by Sadish.