VBS script implements code instances that download JRE packages and silently install _vbs

Source: Internet
Author: User
Tags create directory

After the installation is complete, you can callback, replacing Echo 123456789 and pause.

Dim path
Set ws = CreateObject ("Wscript.Shell")
set Fso=createobject ("Scripting.FileSystemObject")
" Define installation path Path
= ws. ExpandEnvironmentStrings ("%windir%") + "\jre6\" "
Create directory
If (FSO). FolderExists (path)) Then
Else
  fso.createfolder (path) end
If
' file downloads
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)
' Write bat performs the install JRE, outputs 123456789 after completion, and pauses
f.write filename+ "/s installdir=" +path & vbcrlf& "echo 123456789" &vbcrlf& "pause"
f.close "
Hide Run
ws.run (batpath), 0,true

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.