Sunday, February 17, 2013

Finding JRE Version using VBScript

Code Snippet
Set wshShell = WScript.CreateObject("WSCript.shell")
If Err.Number <> 0 Then
Wscript.Quit  
End If
return=WshShell.Run("%comspec%  java -version" ,0,false)  
return = WshShell.Run("%comspec% /c for /f ""tokens=3"" %g in ('java -version 2^>^&1 ^| findstr /i ""version""') do ( @echo %~g ) > %TEMP%\output.txt", 0, true) {
Set oShell = WScript.CreateObject("WScript.Shell")
filename = oShell.ExpandEnvironmentStrings("%TEMP%\output.txt") 
Set objFileSystem = CreateObject("Scripting.fileSystemObject") 
Set oFile = objFileSystem.OpenTextFile(filename, 1) 
text = oFile.ReadAll 
oFile.Close 
msgbox text 

No comments: