I need to figure out how to automatically pull a file from a web server on a
daily basis. Currently this is done manually.

I am not sure which object to use in this task. I have tried the
Scripting.FilsSystemObject, which does not work. After extensive searching I
am unable to come up with a solution. Is there any way to do it with a
VBScript?

Re: VBS automatic HTTP download by Mark

Mark
Mon Jul 17 10:22:47 CDT 2006

Hello cfulton@nbisolutions.com,

> I am not sure which object to use in this task. I have tried the
> Scripting.FilsSystemObject, which does not work. After extensive
> searching I am unable to come up with a solution. Is there any way to
> do it with a VBScript?

You can use the xmlhttp object and the adodb.stream object (in case the remote
file is not a text file):

'---begin script
'GetRemoteBinaryFile.vbs
If WScript.Arguments.Count < 2 Then
WScript.Echo "Usage: GetRemoteBinary URL localname"
WScript.Quit(1)
End If
ImageFile = WScript.Arguments(1)
URL = WScript.Arguments(0)

Set xml = CreateObject("Microsoft.XMLHTTP")
xml.Open "GET", URL, False ', "", ""
xml.Send

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

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

' Do not overwrite an existing file
oStream.savetofile ImageFile, adSaveCreateNotExist

' Use this form to overwrite a file if it already exists
' oStream.savetofile DestFolder & ImageFile, adSaveCreateOverWrite

oStream.close

'---end scrip



Re: VBS automatic HTTP download by Chance

Chance
Mon Jul 17 11:27:09 CDT 2006

It seems that my Google skills are lacking. Thank you very much.
-Chance
"Mark [exmsft]" <MarkIngalls@nospam.nospam> wrote in message
news:c3aa33fbbf9d38c87799b37932a1@msnews.microsoft.com...
> Hello cfulton@nbisolutions.com,
>
>> I am not sure which object to use in this task. I have tried the
>> Scripting.FilsSystemObject, which does not work. After extensive
>> searching I am unable to come up with a solution. Is there any way to
>> do it with a VBScript?
>
> You can use the xmlhttp object and the adodb.stream object (in case the
> remote file is not a text file):
>
> '---begin script
> 'GetRemoteBinaryFile.vbs
> If WScript.Arguments.Count < 2 Then
> WScript.Echo "Usage: GetRemoteBinary URL localname"
> WScript.Quit(1)
> End If
> ImageFile = WScript.Arguments(1)
> URL = WScript.Arguments(0)
>
> Set xml = CreateObject("Microsoft.XMLHTTP")
> xml.Open "GET", URL, False ', "", ""
> xml.Send
>
> set oStream = createobject("Adodb.Stream")
> Const adTypeBinary = 1
> Const adSaveCreateOverWrite = 2
> Const adSaveCreateNotExist = 1
>
> oStream.type = adTypeBinary
> oStream.open
> oStream.write xml.responseBody
>
> ' Do not overwrite an existing file
> oStream.savetofile ImageFile, adSaveCreateNotExist
>
> ' Use this form to overwrite a file if it already exists
> ' oStream.savetofile DestFolder & ImageFile, adSaveCreateOverWrite
>
> oStream.close
>
> '---end script
>
>



Re: VBS automatic HTTP download by Simon

Simon
Tue Jul 18 11:28:47 CDT 2006

why not use ftp.exe with the -i and -s flags and all your commands in a file
referenced by the -s flag

Simon

"Chance" <cfulton@nbisolutions.com> wrote in message
news:eU6sa3bqGHA.2232@TK2MSFTNGP04.phx.gbl...
> It seems that my Google skills are lacking. Thank you very much.
> -Chance
> "Mark [exmsft]" <MarkIngalls@nospam.nospam> wrote in message
> news:c3aa33fbbf9d38c87799b37932a1@msnews.microsoft.com...
>> Hello cfulton@nbisolutions.com,
>>
>>> I am not sure which object to use in this task. I have tried the
>>> Scripting.FilsSystemObject, which does not work. After extensive
>>> searching I am unable to come up with a solution. Is there any way to
>>> do it with a VBScript?
>>
>> You can use the xmlhttp object and the adodb.stream object (in case the
>> remote file is not a text file):
>>
>> '---begin script
>> 'GetRemoteBinaryFile.vbs
>> If WScript.Arguments.Count < 2 Then
>> WScript.Echo "Usage: GetRemoteBinary URL localname"
>> WScript.Quit(1)
>> End If
>> ImageFile = WScript.Arguments(1)
>> URL = WScript.Arguments(0)
>>
>> Set xml = CreateObject("Microsoft.XMLHTTP")
>> xml.Open "GET", URL, False ', "", ""
>> xml.Send
>>
>> set oStream = createobject("Adodb.Stream")
>> Const adTypeBinary = 1
>> Const adSaveCreateOverWrite = 2
>> Const adSaveCreateNotExist = 1
>>
>> oStream.type = adTypeBinary
>> oStream.open
>> oStream.write xml.responseBody
>>
>> ' Do not overwrite an existing file
>> oStream.savetofile ImageFile, adSaveCreateNotExist
>>
>> ' Use this form to overwrite a file if it already exists
>> ' oStream.savetofile DestFolder & ImageFile, adSaveCreateOverWrite
>>
>> oStream.close
>>
>> '---end script
>>
>>
>
>



Re: VBS automatic HTTP download by Jim

Jim
Wed Jul 19 08:41:49 CDT 2006

because then this wouldnt be a VBSCRIPT group



"Simon Whale" <s.whale@nospam.dsl.pipex.com> wrote in message
news:OyrnIdoqGHA.4996@TK2MSFTNGP04.phx.gbl...
> why not use ftp.exe with the -i and -s flags and all your commands in a
> file referenced by the -s flag
>
> Simon
>
> "Chance" <cfulton@nbisolutions.com> wrote in message
> news:eU6sa3bqGHA.2232@TK2MSFTNGP04.phx.gbl...
>> It seems that my Google skills are lacking. Thank you very much.
>> -Chance
>> "Mark [exmsft]" <MarkIngalls@nospam.nospam> wrote in message
>> news:c3aa33fbbf9d38c87799b37932a1@msnews.microsoft.com...
>>> Hello cfulton@nbisolutions.com,
>>>
>>>> I am not sure which object to use in this task. I have tried the
>>>> Scripting.FilsSystemObject, which does not work. After extensive
>>>> searching I am unable to come up with a solution. Is there any way to
>>>> do it with a VBScript?
>>>
>>> You can use the xmlhttp object and the adodb.stream object (in case the
>>> remote file is not a text file):
>>>
>>> '---begin script
>>> 'GetRemoteBinaryFile.vbs
>>> If WScript.Arguments.Count < 2 Then
>>> WScript.Echo "Usage: GetRemoteBinary URL localname"
>>> WScript.Quit(1)
>>> End If
>>> ImageFile = WScript.Arguments(1)
>>> URL = WScript.Arguments(0)
>>>
>>> Set xml = CreateObject("Microsoft.XMLHTTP")
>>> xml.Open "GET", URL, False ', "", ""
>>> xml.Send
>>>
>>> set oStream = createobject("Adodb.Stream")
>>> Const adTypeBinary = 1
>>> Const adSaveCreateOverWrite = 2
>>> Const adSaveCreateNotExist = 1
>>>
>>> oStream.type = adTypeBinary
>>> oStream.open
>>> oStream.write xml.responseBody
>>>
>>> ' Do not overwrite an existing file
>>> oStream.savetofile ImageFile, adSaveCreateNotExist
>>>
>>> ' Use this form to overwrite a file if it already exists
>>> ' oStream.savetofile DestFolder & ImageFile, adSaveCreateOverWrite
>>>
>>> oStream.close
>>>
>>> '---end script
>>>
>>>
>>
>>
>
>