Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Downloading file with VBscript not ASP

Status
Not open for further replies.

dwcandco

Programmer
Aug 21, 2003
7
SI
Hello. I need help.

I would like to download file from internet for example adobe.htm from to c:\. I need script program.vbs. So how can I do it.

Bye
 
Hello dwcando,

I'd posted in the recent past. I post the sketch again see if it helps.

Code:
'-----
Option Explicit

Const sPath = ".\"
Const sURL="[URL unfurl="true"]http://www.adobe.com"[/URL]
Const sSavedFileName="adobe_com.htm"
'Const sURL="[URL unfurl="true"]http://www.tek-tips.com/gviewthread.cfm/lev2/4/lev3/32/pid/329/qid/634926"[/URL]
'Const sSavedFileName="329-634926.htm"


Dim sSavedFullFileName
sSavedFullFileName=sPath & sSavedFileName

WScript.echo "start downloading : "&sURL
GrabberEngine sSavedFullFileName, sURL
WScript.Echo "Download of " & sURL & " to " & sSavedFullFileName & " is complete."

Sub GrabberEngine(sFile, sURL)
  const adTypeBinary = 1
  const adModeReadWrite = 3
  const adSaveCreateOverwrite = 2
  'Error handle adding here particularly after oXML.send if no connection avail
  'Without, let the script failed at runtime.
  Dim oXML,oStream
  set oXML = CreateObject("Microsoft.XMLHTTP")
  oXML.open "GET", sURL, False
  oXML.send
  Set oStream=CreateObject("ADODB.Stream")
  With oStream
    .type = adTypeBinary
    .mode = adModeReadWrite
    .open
    On Error Resume Next
    Do
      Wscript.Sleep 150
      .write oXML.responseBody
    Loop Until Err.number = 0
    On Error Goto 0
    .savetofile sFile, adSaveCreateOverwrite
  End With
  Set oStream=Nothing
End Sub
'-----

regards - tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top