How download from command prompt?


R

Robert Paris

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)

Thanks!
 
Ad

Advertisements

M

Matthias Tacke

M

Mark Hanford

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)

Thanks!

You could possibly use the standard ftp command. This would work for
downloading files, but not really for URL's.

I have a set of commands in a files called get.txt like:

----top of file: get.txt----
myftpusername
myftppassword
prompt
binary
cd /pub/stuff/files
mget *.zip
cd ../../morefiles
mget *.zip
quit
---end of file: get.txt----

then from a batch file I can do something like

----top of file: sync.bat----
@echo off
ftp ftp.somesite.com -s:get.txt
----end of file: sync.bat----


Hope that helps

Mark Hanford
 
M

Mark Hanford

Mark Hanford said:
You could possibly use the standard ftp command. This would work for
downloading files, but not really for URL's.

I have a set of commands in a files called get.txt like:

----top of file: get.txt----
myftpusername
myftppassword
prompt
binary
cd /pub/stuff/files
mget *.zip
cd ../../morefiles
mget *.zip
quit
---end of file: get.txt----

then from a batch file I can do something like

----top of file: sync.bat----
@echo off
ftp ftp.somesite.com -s:get.txt
----end of file: sync.bat----


Hope that helps

Mark Hanford

Hmmm. I've just looked at wget as recommended by Matthias and I'm not sure
how I ever managed without it. Looks much more powerfull...
 
Ad

Advertisements

P

Paul R. Sadowski

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
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top