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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

download file from url 1

Status
Not open for further replies.

bn2hunt

MIS
May 15, 2003
203
US
I need to download a file from a url. This is what I have so far:

Set WshShell = WScript.CreateObject("WScript.Shell")
url="set IEApp = WScript.CreateObject ("InternetExplorer.Application")
IEApp.navigate(url)
IEApp.Visible = TRUE
WSCRIPT.SLEEP 3000
WSHSHELL.SENDKEYS "%S"
WSCRIPT.SLEEP 10000
WSHSHELL.SENDKEYS "%S"

The problems I have with this method are
1: The download window will appear not-active about half of the time then the script errors.
2: I can't specify a download locatin for the file.

Any help on this will be appreciated.

Thanks in advance

Dan
 
Hello dnnwolff,

Check if my previous posting helps:
thread(329-634926)

regards - tsuji
 
That worked just like I needed. I did a search on the subject but your post didn't come up for some reason.

Thanks for the help

Ddnwolff
 
What scripting language did you write this in? I would like to work with the file after downloading it, like unzip it, and read the file that I unzipped but I'm getting error messages on the commands I am using(see below)

Set WshShell = CreateObject("WSCRIPT.Shell")
unziplit = sPath & "/" & zipfile
const zipfile = "Doctor_Download_Beta.zip"
runlit = chr(34) & "C:\Program Files\WinZip\WZUNZIP.EXE" & chr(34) & " -o " & unziplit & " " & ziploc
ziperr = wshshell.run(runlit,0,true)

This works if I put it in a seperate script and run it but when I added it to the code you provided it blows up on the frist line.

Thanks

Dan
 
ddnwolff,

It is on wsh as a standalone.

A quick look on your lines, I would suggest put the Const up before you assign it to unziplit. Post back if it is still not working for your .Run(runlit,0,true) line.

regards - tsuji
 
hello again,

Looking at the thread I referred you to, I think the problem simply stems from the Option Explicit. If you want to keep that statement, dim all your variables.

As to moving up the line of Const declared, it makes the script better structured, but, it won't resolve the error you encountered.

Also, it won't matter if you use vbscript.dll to instantiate "WScript.Shell" or use native wscript.exe to create it. But, choose one way or another to be consistent.

-tsuji
 
I removed the option explicit line and moved some lines around to make it more uniform ie varialbe declaration in same spots, and it is working know. What does the option explicit do? I am new to scripting and havn't seen that before.

Thanks

Dan
 
It's mainly to prevent typo with variable names.
When Option Explicit is on, you get an error if you use a variable not previously declared with a Dim instruction.

Hope This Help
PH.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top