首页 > 编程 > VBScript > 正文

vbs脚本实现下载jre包并静默安装的代码实例

2020-07-26 11:46:04
字体:
来源:转载
供稿:网友

安装完成后可以回调,替换echo 123456789和pause就行了。

dim pathset ws = CreateObject("WScript.Shell")set fso=createobject("scripting.filesystemobject")''定义安装路径path = ws.ExpandEnvironmentStrings("%windir%")+"/jre6/"''创建目录If (fso.FolderExists(path)) ThenElse  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.CloseEnd Subdim urlurl = "http://xxx.com/jre-6-windows-i586.exe"dim fileName,batpathfileName = path+Right(url, Len(url) - InStrRev(url,"/"))DownloadToFile url, fileNamebatpath = path+"start.bat"set f=fso.createtextfile(batpath)''写bat执行安装jre,完成后输出123456789,并暂停f.write fileName+" /s INSTALLDIR="+path& vbcrlf&"echo 123456789"&vbcrlf&"pause"f.close''隐藏运行ws.run(batpath),0,true

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表