Navigation

Search

Categories

On this page

How to snag a file from a URL using VBScript

Archive

Blogroll

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

RSS 2.0 | Atom 1.0 | CDF

Send mail to the author(s) E-mail

Total Posts: 120
This Year: 1
This Month: 0
This Week: 0
Comments: 40

Sign In
Pick a theme:

# Tuesday, August 16, 2005
Tuesday, August 16, 2005 10:43:08 AM (Mountain Daylight Time, UTC-06:00) ( )
DailyFile.vbs

Option Explicit

Dim today
Dim yesterday
Dim strYesterday
nToday=Date()
nYesterday=DateAdd("d",-1,nToday)
sYesterday=CStr(FormatDateTime(nYesterday,2))

Dim sBackupFile=Replace(sYesterday, "/", "_")    
Dim sDestFolder="C:\"
Dim sURL="https://domain/share/" & sBackupFile

Dim sUser=""                                 
Dim sPass=""

Set oHttp = CreateObject("Microsoft.XMLHTTP")
oHttp.Open("GET", sURL, False, sUser, sPass)
oHttp.Send ""

set saveFile = createobject("Adodb.Stream")
Const adTypeBinary = 1
Const adSaveCreateOverWrite = 2

saveFile.type = adTypeBinary
saveFile.open
saveFile.write xml.responseBody

saveFile.savetofile sDestFolder & sBackupFile, adSaveCreateOverWrite

saveFile.close

set saveFile = nothing
Set oHttp = Nothing

Comments [2] | | #