3
5
2008
5
2008
Java環境變數自動設定
Set WSHShell=CreateObject("Wscript.shell")
Dim JavaVer,HomePath,EnvPath,Temp
EnvPath ="HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\"
JavaVer = WshShell.RegRead("HKLM\SOFTWARE\JavaSoft\Java Runtime Environment\CurrentVersion")
HomePath = WshShell.RegRead("HKLM\SOFTWARE\JavaSoft\Java Runtime Environment\"+JavaVer+"\JavaHome")
Temp = WshShell.RegRead(EnvPath+"Path")
WshShell.RegWrite EnvPath+"Path", Temp+";"+HomePath+"\bin","REG_EXPAND_SZ"
WshShell.RegWrite EnvPath+"ClassPath",".;"+HomePath+"\lib", "REG_SZ"
WshShell.RegWrite EnvPath+"JAVA_HOME", HomePath, "REG_SZ"
WshShell.RegWrite EnvPath+"JRE_HOME", HomePath, "REG_SZ"
MsgBox "Java環境變數設定完成!", vbInformation, "寫入完成"
Dim JavaVer,HomePath,EnvPath,Temp
EnvPath ="HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\"
JavaVer = WshShell.RegRead("HKLM\SOFTWARE\JavaSoft\Java Runtime Environment\CurrentVersion")
HomePath = WshShell.RegRead("HKLM\SOFTWARE\JavaSoft\Java Runtime Environment\"+JavaVer+"\JavaHome")
Temp = WshShell.RegRead(EnvPath+"Path")
WshShell.RegWrite EnvPath+"Path", Temp+";"+HomePath+"\bin","REG_EXPAND_SZ"
WshShell.RegWrite EnvPath+"ClassPath",".;"+HomePath+"\lib", "REG_SZ"
WshShell.RegWrite EnvPath+"JAVA_HOME", HomePath, "REG_SZ"
WshShell.RegWrite EnvPath+"JRE_HOME", HomePath, "REG_SZ"
MsgBox "Java環境變數設定完成!", vbInformation, "寫入完成"