VBS脚本设置Java环境变量

转自 http://blog.csdn.net/sunyujia/article/details/2896518

 

Set shell = CreateObject("Shell.Application")  
Set selFolder = shell.BrowseForFolder(0, "请选择JAVA_HOME目录", 0, ssfDRIVES)  
Set selFolderItem = selFolder.Self  
selPath = selFolderItem.Path
dim wsh
Set wsh = WScript.CreateObject("WScript.Shell")
wsh.Environment("system").Item("JAVA_HOME")=selPath
wsh.Environment("system").Item("classpath")=".;%java_home%\lib\tools.jar;%java_home%\lib\dt.jar"
wsh.Environment("system").Item("path")="%java_home%\bin;"+wsh.Environment("system").Item("path")
 
msg0 = "完成JAVA环境变量设置"+vbcrlf
msg1 = "JAVA_HOME = "+ wsh.Environment("system").Item("JAVA_HOME") + vbcrlf
msg2 = "classpath = "+ wsh.Environment("system").Item("classpath") + vbcrlf
msg3 = "path = "+ wsh.Environment("system").Item("path")

MsgBox msg0+msg1+msg2+msg3

 

双击运行,选择完jdk路径后,程序会设置java_home、classpath、path~

你可能感兴趣的:(java)