vbs脚本实现下载jre包并静默安装的代码实例
程序员文章站
2022-03-21 16:41:13
安装完成后可以回调,替换echo 123456789和pause就行了。
dim path
set ws = createobject("wscript.she...
安装完成后可以回调,替换echo 123456789和pause就行了。
dim path set ws = createobject("wscript.shell") set fso=createobject("scripting.filesystemobject") ''定义安装路径 path = ws.expandenvironmentstrings("%windir%")+"\jre6\" ''创建目录 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) ''写bat执行安装jre,完成后输出123456789,并暂停 f.write filename+" /s installdir="+path& vbcrlf&"echo 123456789"&vbcrlf&"pause" f.close ''隐藏运行 ws.run(batpath),0,true