Robert Paris said:
Is there a way to download files in a command prompt (or ".bat" file)?
Can I use internet explorer from a command prompt? If so, does anyone have
links to how to do that? (And how I could download a URL into a file using
IE from a command prompt)
While wget is easiest one can do it with the scripting host as well. Such
as:
Set WshShell = WScript.CreateObject("WScript.Shell")
Desktop = FixPath(WshShell.SpecialFolders("Desktop"))
sSrcUrl = "
http://www.paulsadowski.com/images/"
sDestFolder = Desktop
sImageFile = "pscom.gif"
sContentTypeExpected = "image/gif"
'sContentTypeExpected = "image/jpeg"
'sContentTypeExpected = "application/octet-stream"
set oHTTP = CreateObject("msxml2.XMLHTTP")
'from ASP==> set oHTTP = CreateObject("msxml2.ServerXMLHTTP")
oHTTP.open "GET", sSrcUrl & sImageFile, False
oHTTP.send
if oHTTP.status <> 200 then
msgbox "unexpected status = " _
& oHTTP.status & vbcrlf _
& oHTTP.statusText
wscript.quit
end if
sContentTypeReturned = oHTTP.getResponseHeader("content-type")
if sContentTypeReturned <> sContentTypeExpected then
msgbox "unexpected content-type = " & sContentTypeReturned & vbcrlf &
"expected = " & sContentTypeExpected
wscript.quit
end if
set oStream = createobject("adodb.stream")
Const adTypeBinary = 1
Const adSaveCreateOverWrite = 2
Const adSaveCreateNotExist = 1
oStream.type = adTypeBinary
oStream.open
oStream.write oHTTP.responseBody
'oStream.savetofile sDestFolder & sImageFile, adSaveCreateOverWrite
oStream.savetofile sDestFolder & sImageFile, adSaveCreateNotExist
msgbox oStream.Size
set oStream = nothing
set oHTTP = nothing
msgbox "Done..." & vbCRLF & "Downloaded " & sImageFile & " to " & Desktop &
sImageFile
Function FixPath(string)
x = Len(string)
if mid(string, x, 1) <> "\" then
string = string & "\"
end if
FixPath = string
End Function