标签:object 变量 comm mic 自动 output mob file dir
Oracle JDK 要收费了,Open JDK没有安装包,只有Zip,写了个安装脚本 InstallOpenJDK.vbs
1 Rem ********************************* 2 Rem **File: InstallOpenJDK.vbs 3 Rem **Author: windfic 4 Rem **Date: 2019-06-05 5 Rem **Description: 自动安装OpenJDK 6 Rem ********************************* 7 8 9 Rem ==把指定目录加入注册表== 10 sub PathToRegPath(Path, Reg) 11 Set oWshShell = WScript.CreateObject("WScript.Shell") 12 13 OldPath = oWshShell.RegRead(Reg) 14 15 if InStr(OldPath, Path) <= 0 then 16 NewPath = OldPath & ";" & Path 17 oWshShell.RegWrite Reg, NewPath 18 end if 19 end sub 20 21 Rem ==把指定目录加入系统Path== 22 sub PathToSystemPath(Path) 23 PathToRegPath Path, "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment\Path" 24 end sub 25 26 Rem ==安装JDK== 27 sub InstallJDK(Path) 28 Set oWshShell = WScript.CreateObject("WScript.Shell") 29 Set oFs=WScript.CreateObject("Scripting.FileSystemObject") 30 31 if oFs.FolderExists(Path) then 32 Home = oFs.GetAbsolutePathName(Path) 33 else 34 Set oFolder = oFs.GetFile(Wscript.ScriptFullName).ParentFolder 35 Home = oFolder.Path & "\" & Path 36 end if 37 38 if oFs.FolderExists(Home) then 39 Rem 设置JAVA_HOME 40 oWshShell.RegWrite "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment\JAVA_HOME", Home 41 42 Rem 把bin加入系统目录 43 PathToSystemPath "%JAVA_HOME%\bin" 44 else 45 MsgBox("目录:" & Path & " 不存在。") 46 end if 47 48 end sub 49 50 Rem ==安装JRE== 51 sub InstallJRE(Path) 52 Set oWshShell = WScript.CreateObject("WScript.Shell") 53 Set oFs=WScript.CreateObject("Scripting.FileSystemObject") 54 55 if oFs.FolderExists(Path) then 56 Home = oFs.GetAbsolutePathName(Path) 57 else 58 Set oFolder = oFs.GetFile(Wscript.ScriptFullName).ParentFolder 59 Home = oFolder.Path & "\" & Path 60 end if 61 62 if oFs.FolderExists(Home) then 63 Rem 生成jre目录 64 oWshShell.CurrentDirectory = Home 65 CommandLine = "bin\jlink.exe --module-path jmods --add-modules java.desktop --output jre" 66 oWshShell.Exec(CommandLine) 67 68 Rem 设置JRE_HOEM 69 Home = Home & "\jre" 70 oWshShell.RegWrite "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment\JRE_HOEM", Home 71 72 Rem 设置CLASSPATH 73 CLASSPATH = ".;%JAVA_HOME%\lib;%JAVA_HOME%\jre\lib" 74 oWshShell.RegWrite "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment\CLASSPATH", CLASSPATH 75 76 Rem 把jre\bin加入系统目录 77 PathToSystemPath "%JAVA_HOME%\jre\bin" 78 end if 79 80 end sub 81 82 83 Rem ========================主程序================================ 84 85 JavaHome = "D:\java\jdk-12" 86 87 InstallJDK JavaHome 88 InstallJRE JavaHome 89 90 MsgBox("执行完成。")
注:环境变量设置方法来自网络
(完)
OpenJDK自动安装脚本 InstallOpenJDK.vbs
标签:object 变量 comm mic 自动 output mob file dir
原文地址:https://www.cnblogs.com/windfic/p/10980942.html