1
我正在嘗試自動安裝Java來設置新機器。 我打算將java下載到網絡上的目錄,並讓腳本從那裏安裝。 我希望腳本確定32位和64位安裝程序,而不必每次下載新的安裝程序時更改腳本。Vbscript安裝最新的Java版本
我該如何去用通配符運行文件路徑?
這裏是我迄今爲止
這就決定了建築
Function GetArch
Dim WshShell
Dim WshProcEnv
Dim system_architecture
Dim process_architecture
Set WshShell = CreateObject("WScript.Shell")
Set WshProcEnv = WshShell.Environment("Process")
process_architecture= WshProcEnv("PROCESSOR_ARCHITECTURE")
If process_architecture = "x86" Then
system_architecture= WshProcEnv("PROCESSOR_ARCHITEW6432")
If system_architecture = "" Then
system_architecture = "x86"
End if
Else
system_architecture = process_architecture
End If
'WScript.Echo "Running as a " & process_architecture & " process on a " & system_architecture & " system."
GetArch = system_architecture
End Function
這將運行可執行
Function runExec(strExec,blWait)
Dim objShell
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run strExec, 1 ,blWait
Set objShell = Nothing
End Function
希望這將安裝Java
Function InstallJava
if Instr(1, GetArch, "64") then
runExec "\\fs1\IT\Scripts\Java\jre-*-x64.exe",true
InstallJava = "Java 64bit Installed"
ElseIf Instr(1, GetArch, "86") then
runExec "\\fs1\IT\Scripts\Java\jre-*-i586.exe",true
InstallJava = "Java 32bit Installed"
End If
End Function