• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 916
  • Last Modified:

VBS with a URL

I have this in a vbs file I created. The point is to for this to download the .txt file. But for some reason it prints the txt file on a explorer window. Is there a way I can force it to download. Please help

Dim ie, strURL, x
strURL = "ftp://gdhse:tygfdtk9@gthe.net/idx/idx_dn/sdf.txt"
Set ie = WScript.CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.Navigate strURL
Do while ie.busy: x=x+300000000000: loop

0
eteran
Asked:
eteran
  • 3
  • 3
  • 2
1 Solution
 
basicinstinctCommented:
hi, that's what "InternetExplorer.Application" is for, it creates an instance of a web browser that you can control thru script...

if it was me i'd be bypassing the browser all together and try to work out how to make an http get request from vbscript... probably need to download a third party vbscript library for it...  a quick google search brought up these promising results:

http://www.activexperts.com/activsocket/howto/http/vbscript/
http://www.example-code.com/vbscript/http_get.asp
0
 
discon0Commented:
You can download the file with Internet Explorer but I suggest you don't use it. See this page:

I suggest you use the following script to download a file:

Dim strURL, strTargetPath, objXH, objBS

strURL = "http://localhost/info.txt"
strTargetPath = "C:\info.txt"

Set objXH = CreateObject("Microsoft.XMLHTTP")
objXH.Open "GET", strURL, False
objXH.Send

objResponse = objXH.ResponseBody

Set objBS = CreateObject("ADODB.Stream")
objBS.Type = 1 'Binary
objBS.Open
objBS.Write objResponse
objBS.SaveToFile strTargetPath, 2 '1=adSaveCreateNotExist, 2=adSaveCreateOverWrite
objBS.Close

Set objBS = Nothing
Set objXH = Nothing
0
 
discon0Commented:
Forgot to add the link to the example using Internet Explorer:
http://www.experts-exchange.com/Programming/Q_20972098.html
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
eteranAuthor Commented:
But I am not programming anything. I need to down load some data daily from a server that is saved in .txt format. Is there a way for me to twick my explorer window not to view the .txt file but to download.
0
 
discon0Commented:
Try the code I posted. It's similar to your code but works exactly like you want it- downloads a file.

All you need to do is put the code in a text file, change the 2nd & 3rd line to your URL and where you want it to save the file and then save it as a VBS file.

If you wanted, you could also add a scheduled task that runs this daily.
0
 
basicinstinctCommented:
>>But I am not programming anything.

This sure looks like programming to me:

Dim ie, strURL, x
strURL = "ftp://gdhse:tygfdtk9@gthe.net/idx/idx_dn/sdf.txt"
Set ie = WScript.CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.Navigate strURL
Do while ie.busy: x=x+300000000000: loop


Why don't you use FTP instead, download a scriptable client like WinSCP (http://winscp.net/) and write a script that downloads your file every day.
0
 
eteranAuthor Commented:
How would I go about building a script for that any idea. I have not programmed in that before, can you post a sample code.
0
 
basicinstinctCommented:
howdy, ok, i just noticed your url is already using the ftp protocol, so forget what i said about http get.

it seems you don't want to do any programming, so you should grab an FTP client that can be scheduled or scripted, as i mentioned above.

if we take winscp as an example...  

1. download and install winscp
2. Add a new scheduled task as documented here:
http://winscp.net/eng/docs/faq_schedule
BUT instead of the command they show as an example you'd want something like this:

C:\Program Files\WinSCP\WinSCP.exe /command open user:password@example.com get /idx/idx_dn/sdf.txt exit

Something like that, you'd have to tweak the command:
http://winscp.net/eng/docs/script_commands#get
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now