View Full Version : How download from command prompt?


Robert Paris
02-09-2004, 04:31 PM
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!

Matthias Tacke
02-09-2004, 05:07 PM
"Robert Paris" wrote:

>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)
>
Use wget, the most recent version seems to be
http://prdownloads.sourceforge.net/gnuwin32/wget-1.9-1-bin.zip
and the doc is:
http://prdownloads.sourceforge.net/gnuwin32/wget-1.9-1-doc.zip

HTH
--
Greetings
Matthias________________________________________
For help on nt commands enter in a cmd window:
W2K>HH windows.chm::ntcmds.htm XP>HH ntcmds.chm

Matthias Tacke
02-09-2004, 05:07 PM
"Robert Paris" wrote:

>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)
>
Use wget, the most recent version seems to be
http://prdownloads.sourceforge.net/gnuwin32/wget-1.9-1-bin.zip
and the doc is:
http://prdownloads.sourceforge.net/gnuwin32/wget-1.9-1-doc.zip

HTH
--
Greetings
Matthias________________________________________
For help on nt commands enter in a cmd window:
W2K>HH windows.chm::ntcmds.htm XP>HH ntcmds.chm

Robert Paris
02-09-2004, 05:16 PM
Thanks!

"Matthias Tacke" <Matthias@Tacke.de> wrote in message
news:c08ep2$t74$00$1@news.t-online.com...
> "Robert Paris" wrote:
>
> >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)
> >
> Use wget, the most recent version seems to be
> http://prdownloads.sourceforge.net/gnuwin32/wget-1.9-1-bin.zip
> and the doc is:
> http://prdownloads.sourceforge.net/gnuwin32/wget-1.9-1-doc.zip
>
> HTH
> --
> Greetings
> Matthias________________________________________
> For help on nt commands enter in a cmd window:
> W2K>HH windows.chm::ntcmds.htm XP>HH ntcmds.chm

Robert Paris
02-09-2004, 05:16 PM
Thanks!

"Matthias Tacke" <Matthias@Tacke.de> wrote in message
news:c08ep2$t74$00$1@news.t-online.com...
> "Robert Paris" wrote:
>
> >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)
> >
> Use wget, the most recent version seems to be
> http://prdownloads.sourceforge.net/gnuwin32/wget-1.9-1-bin.zip
> and the doc is:
> http://prdownloads.sourceforge.net/gnuwin32/wget-1.9-1-doc.zip
>
> HTH
> --
> Greetings
> Matthias________________________________________
> For help on nt commands enter in a cmd window:
> W2K>HH windows.chm::ntcmds.htm XP>HH ntcmds.chm

Mark Hanford
02-09-2004, 05:23 PM
"Robert Paris" <rpjava@hotmail.com> wrote in message
news:eCd7Ooy7DHA.696@tk2msftngp13.phx.gbl...
> 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

Mark Hanford
02-09-2004, 05:23 PM
"Robert Paris" <rpjava@hotmail.com> wrote in message
news:eCd7Ooy7DHA.696@tk2msftngp13.phx.gbl...
> 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

Mark Hanford
02-09-2004, 05:32 PM
"Mark Hanford" <stuff-ms@hanfordonline.nojunk.co.spaminacan.uk> wrote in
message news:uyO$FGz7DHA.3648@TK2MSFTNGP11.phx.gbl...
> "Robert Paris" <rpjava@hotmail.com> wrote in message
> news:eCd7Ooy7DHA.696@tk2msftngp13.phx.gbl...
> > 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
>

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...

Mark Hanford
02-09-2004, 05:32 PM
"Mark Hanford" <stuff-ms@hanfordonline.nojunk.co.spaminacan.uk> wrote in
message news:uyO$FGz7DHA.3648@TK2MSFTNGP11.phx.gbl...
> "Robert Paris" <rpjava@hotmail.com> wrote in message
> news:eCd7Ooy7DHA.696@tk2msftngp13.phx.gbl...
> > 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
>

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...

Paul R. Sadowski
02-09-2004, 08:33 PM
"Robert Paris" <rpjava@hotmail.com> wrote in message
news:eCd7Ooy7DHA.696@tk2msftngp13.phx.gbl...
> 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

Paul R. Sadowski
02-09-2004, 08:33 PM
"Robert Paris" <rpjava@hotmail.com> wrote in message
news:eCd7Ooy7DHA.696@tk2msftngp13.phx.gbl...
> 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