QTP脚本设置java环境变量

发表于:2008-04-29来源:作者:点击数: 标签:qtpQTP脚本javaJAVA
QTP 脚本设置java环境变量 ''''''''''''''''''''''''''''''''''''''' 'This qtp scriptis used for setting the java environment variable automaticly. 'save the scirptunder the JDKfolder 'author :yks(YangKongSuo) 'if forward this script please in
QTP脚本设置java环境变量

'''''''''''''''''''''''''''''''''''''''
'This qtp script  is used for setting the java environment variable automaticly.
'save the scirpt  under the JDK  folder
'author :  yks(YangKongSuo)
'if forward this script please indicate the author
''''''''''''''''''''''''''''''''''''''''
Dim fso,wsh,env_path,classpath,TestDir
Set fso = CreateObject("Scripting.FileSystemObject")
TestDir = Environment("TestDir")
J2SDK_path = fso.GetParentFolderName(TestDir)
Set wsh = CreateObject("WScript.Shell")
If not  fso.FileExists(J2SDK_path&"\bin\java.exe") then
msgbox (J2SDK_path&"\bin\java.exe not existing")
ExitTest
else
wsh.Environment("system").Item("JAVA_HOME")=J2SDK_path
    env_path = wsh.Environment("system").Item("PATH")
If  instr(1,env_path, ";" & J2SDK_path & "\bin",1) = 0 Then
  wsh.Environment("system").Item("PATH")=env_path & ";" & J2SDK_path & "\bin"
End If
classpath = wsh.Environment("system").Item("CLASSPATH")
If instr(1,classpath, ".;"&J2SDK_path&"\lib\tools.jar",1) = 0 Then
  wsh.Environment("system").Item("CLASSPATH")=classpath & ".;"&J2SDK_path&"\lib\tools.jar"
  classpath = wsh.Environment("system").Item("CLASSPATH")
  wsh.Environment("system").Item("CLASSPATH")=classpath&";"&J2SDK_path&"\lib\dt.jar"
  classpath = wsh.Environment("system").Item("CLASSPATH")
  wsh.Environment("system").Item("CLASSPATH")=classpath&";"&J2SDK_path&"\jre\lib\rt.jar"
End If  
end if

原文转自:http://www.ltesting.net