-
Notifications
You must be signed in to change notification settings - Fork 3
/
getWebFile1.vbs
executable file
·36 lines (26 loc) · 1 KB
/
getWebFile1.vbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
' Called from windows command line like this:
' > Cscript.exe getWebFile1.vbs "http://www.cygwin.com/setup.exe" "C:\cygwin\setup.exe"
' Get the command line arguments
Set objArgs = WScript.Arguments
' Set your settings
strFileURL = objArgs(0)
strHDLocation = objArgs(1)
'strHDLocation = "C:\Temp\cygwin_setup.exe"
' Fetch the file
Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
objXMLHTTP.open "GET", strFileURL, false
objXMLHTTP.send()
If objXMLHTTP.Status = 200 Then
Set objADOStream = CreateObject("ADODB.Stream")
objADOStream.Open
objADOStream.Type = 1 'adTypeBinary
objADOStream.Write objXMLHTTP.ResponseBody
objADOStream.Position = 0 'Set the stream position to the start
Set objFSO = Createobject("Scripting.FileSystemObject")
If objFSO.Fileexists(strHDLocation) Then objFSO.DeleteFile strHDLocation
Set objFSO = Nothing
objADOStream.SaveToFile strHDLocation
objADOStream.Close
Set objADOStream = Nothing
End if
Set objXMLHTTP = Nothing