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
新建一个记事本 然后将以上的内容复制到记事本里面然后另存为“xxx.vbs”,双击该文件运行!选择jdk的安装路径,点击OK,JDK的环境变量配置就搞定了!是不是很easy啊!