Need a script to search Path of a file and set PATH variable
The requirement is to set PATH environment variable with the version of JAVA JDK installed on the machine.
The application requires JAVA JDK 1.6 and above installed on the machine. There are many versions of JAVA JDK available in our PROD environment, so my task is the search for the version of Java installed on the machine and then add the path (ex; C:\Program File\Java\jdk1.6.0_20\bin) to the system PATH environment variable. Let me know if this is possible with VB script or Batch script.
Use the VBScript illustrated below.
Community Chosen Answer
thanks all for your help... The below script did the job for me..
Dim FSO, OFWindows,OWinFolders,OWinFolder, fullpath,objshell,objsysEnv, final
Set FSO= CreateObject("Scripting.FileSystemObject")
final = "\bin"
Set objshell= CreateObject("Wscript.Shell")
Set OFWindows= FSO. GetFolder("C:\Program Files (x86)\Java")
Set OWinFolders= OFWindows.SubFolders
For each OWinFolder in OWinFolders
If UCase(left(OWinFolder.name, 3))="jdk" then fullpath= OWinFolder.path
'Set objSysEnv= objshell.Environment("SYSTEM")
'objsysEnv("PATH")=objsysEnv("PATH") & ";" & fullpath & final