Navigation

Search

Categories

On this page

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] | | # 
Tuesday, September 20, 2005 10:25:23 PM (Mountain Daylight Time, UTC-06:00)
Christianity and Code seem to go together for me too. See 'brucethinx.blogspot.com' and 'codeaholic.blogspot.com' respectively.

By the way, I've wondered often how to do binary file stuff in VBScript and above I see the answer. That and how to do downloads makes this visit very worthwhile.

Thanks,
Bruce.
Tuesday, September 20, 2005 10:36:42 PM (Mountain Daylight Time, UTC-06:00)
Hmm ... are you sure this is VBScript? I had to turn a lot of
Dim this=that
into
Dim this
this=that

and there were a few undeclared variables. Did you put "Option Explicit" on as an afterthought?

Regards,
Bruce.
Comments are closed.