dim path
set ws = CreateObject("WScript.Shell")
set fso=createobject("scripting.filesystemobject")
''定義安裝路徑
path = ws.ExpandEnvironmentStrings("%windir%")+"\jre6\"
''創(chuàng)建目錄
If (fso.FolderExists(path)) Then
Else
fso.createfolder(path)
End If
''文件下載
Set xPost = CreateObject("Microsoft.XMLHTTP")
Set sGet = CreateObject("ADODB.Stream")
Sub DownloadToFile(url, file)
xPost.Open "GET", url, False
xPost.Send
sGet.Type = 1
sGet.Open
sGet.Write xPost.responseBody
sGet.SaveToFile file, 2
sGet.Close
End Sub
dim url
url = "http://xxx.com/jre-6-windows-i586.exe"
dim fileName,batpath
fileName = path+Right(url, Len(url) - InStrRev(url,"/"))
DownloadToFile url, fileName
batpath = path+"start.bat"
set f=fso.createtextfile(batpath)
''寫(xiě)bat執(zhí)行安裝jre,完成后輸出123456789,并暫停
f.write fileName+" /s INSTALLDIR="+path vbcrlf"echo 123456789"vbcrlf"pause"
f.close
''隱藏運(yùn)行
ws.run(batpath),0,true