Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Downloading a file

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,3205
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Downloading a file
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1] 2   next >   >>
Login
Message << Older Topic   Newer Topic >>
 Downloading a file - 6/2/2005 8:44:24 PM   
  TNO


Posts: 1064
Score: 10
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
Okay. You've probably read my other posts up to now. This is a followup.
The following code is what I've ultimately come up with. it will allow you to download a file from the internet to your computer:

'GetRemoteBinaryFile.vbs
ImageFile = "back.gif"
DestFolder = "C:\"
URL = "http://www.paulsadowski.com/images/back.gif"

Set xml = CreateObject("Microsoft.XMLHTTP")
xml.Open "GET", URL, False
xml.Send

set oStream = createobject("Adodb.Stream")
Const adTypeBinary = 1
Const adSaveCreateOverWrite = 2
Const adSaveCreateNotExist = 1

oStream.type = adTypeBinary
oStream.open
oStream.write xml.responseBody

' Do not overwrite an existing file
oStream.savetofile DestFolder & ImageFile, adSaveCreateNotExist

' Use this form to overwrite a file if it already exists
' oStream.savetofile DestFolder & ImageFile, adSaveCreateOverWrite

oStream.close

set oStream = nothing
Set xml = Nothing


I am still unsure of how to download a file from an https:// website. Any input you can ive would be appreciated.

_____________________________

To iterate is human, to recurse divine. -- L. Peter Deutsch
 
 
Post #: 1
 
 Re: Downloading a file - 6/3/2005 12:53:49 AM   
  tnoonan

 

Posts: 364
Score: 0
Joined: 12/14/2004
From:
Status: offline
http://curl.haxx.se/docs/manpage.html

(in reply to TNO)
 
 
Post #: 2
 
 Re: Downloading a file - 6/4/2005 9:39:16 PM   
  atu

 

Posts: 33
Score: 0
Joined: 6/1/2005
From:
Status: offline
code u had given is not working on http://geocities.com/tasleem445/nam2.jpg
can u please explain why is it so.I do need this code for some project and it would give me a lot of pleasure if you can solve my this problem.Do help.
Thanks.

(in reply to TNO)
 
 
Post #: 3
 
 Re: Downloading a file - 6/5/2005 10:55:28 AM   
  TNO


Posts: 1064
Score: 10
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
The code is not working because there's a 404 error every time I try to access the page/file.

(in reply to TNO)
 
 
Post #: 4
 
 Re: Downloading a file - 6/5/2005 1:22:56 PM   
  atu

 

Posts: 33
Score: 0
Joined: 6/1/2005
From:
Status: offline
can u predict the reason why is it so n do u have any other idea or code which can download a file from a website without prompting the user.Do Help.
Thanks

(in reply to TNO)
 
 
Post #: 5
 
 Re: Downloading a file - 6/5/2005 3:06:21 PM   
  TNO


Posts: 1064
Score: 10
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
ummm....what?

First off, this code won't prompt the user.
Second, the reason its not working is because you gave a bum link.

I also have no idea if .htaccess rules will interfere or not.

(in reply to TNO)
 
 
Post #: 6
 
 Re: Downloading a file - 6/8/2005 12:36:24 AM   
  atu

 

Posts: 33
Score: 0
Joined: 6/1/2005
From:
Status: offline
Just for the sake of my problem to be solved can you please write this code for me in an html format(i.e.If i have to make a webpage which includes this code).If you can solve my problem i would be much grateful to you.Do help.
Thanks.

(in reply to TNO)
 
 
Post #: 7
 
 Re: Downloading a file - 6/8/2005 10:44:17 AM   
  TNO


Posts: 1064
Score: 10
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
So you want an html page to auto download a picture to your computer? Why? your computer usually does this anyway. Take a look in your Temporary Internet folder.

C:\Documents and Settings\USERNAME\Local Settings\Temporary Internet Files\

(in reply to TNO)
 
 
Post #: 8
 
 Re: Downloading a file - 6/8/2005 4:35:37 PM   
  atu

 

Posts: 33
Score: 0
Joined: 6/1/2005
From:
Status: offline
Thanks for your concern but i want to do this thing programmatically.As i requested if you can please help me to write an html page which performs this job.If you can please write it for me i would be much grateful to you as i don't have much idea about the web and i think that i am making some mistake anywhere because of which the picture is not downloading.Do help.
Thanks.

(in reply to TNO)
 
 
Post #: 9
 
 Re: Downloading a file - 6/9/2005 12:20:19 AM   
  Nembo

 

Posts: 5
Score: 0
Joined: 5/23/2005
From: Germany
Status: offline
I have a problem with it,too.
Because .. i want it to get some files to check, whether my script has to download an update.

I want to use it in this way
quote:
Set FSO = WScript.CreateObject("Scripting.FileSystemObject")
Set Folder = FSO.GetFolder(".")

Function getremfile(ImageFile,DestFolder,URL)
Set xml = CreateObject("Microsoft.XMLHTTP")
xml.Open "GET", URL, False
xml.Send
set oStream = createobject("Adodb.Stream")
Const adTypeBinary = 1
Const adSaveCreateOverWrite = 2
Const adSaveCreateNotExist = 1
oStream.type = adTypeBinary
oStream.open
oStream.write xml.responseBody
oStream.savetofile DestFolder & ImageFile, adSaveCreateNotExist
oStream.close
set oStream = nothing
Set xml = Nothing
End Function

getremfile "loginupdate.ini",Folder&"\","[...]/loginupdate.ini"
getremfile "loginupdate.vbs",Folder&"\","[...]/loginupdate.vbs"

It works fine, but the ini file looks like this:
quote:
[Updater]#ver=18#size=0#[Files]#File0[...]

"#" is this stupid little box which should be "\n"
In this way my script can't read the ini file.

The file have to look like this:
quote:
[Updater]
ver=18
size=0
[Files]
File0 [...]

Is there any way to fix this ?
I dont know much about working with strings in VBS.

I just know about the PHP command
$stringname = str_replace("#","\n",$stringname);

(in reply to TNO)
 
 
Post #: 10
 
 Re: Downloading a file - 6/9/2005 11:27:31 AM   
  TNO


Posts: 1064
Score: 10
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
For atu:

Check this site for some helpful info:
http://www.ericphelps.com/scripting/samples/BinaryDownload/


For Nembo:

you have this:
[Updater]#ver=18#size=0#[Files]#File0[...]

and you want this?:
[Updater]
ver=18
size=0
[Files]
File0 [...]


Use the Split() and Join() functions to do this
Split by #
Join by vbnewline

(in reply to TNO)
 
 
Post #: 11
 
 Re: Downloading a file - 6/9/2005 1:04:57 PM   
  atu

 

Posts: 33
Score: 0
Joined: 6/1/2005
From:
Status: offline
Hello.I have tried this many times but its not working.Atleast i am having difficulty in executing this code.And i really don't know the reason of the failure.You please help me so my problem can be solved.Do help.
Thanks.

(in reply to TNO)
 
 
Post #: 12
 
 Re: Downloading a file - 6/9/2005 1:29:42 PM   
  TNO


Posts: 1064
Score: 10
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
What code?

(in reply to TNO)
 
 
Post #: 13
 
 Re: Downloading a file - 6/9/2005 8:55:40 PM   
  atu

 

Posts: 33
Score: 0
Joined: 6/1/2005
From:
Status: offline
the code which you have given at the top for downloading a picture from a website without even prompting user.please write an html page which include this code.i think i am making some mistake somewhere.So please write this code for me and paste it as a reply here.i am really stuck.Please please please do help.
Thanks.

(in reply to TNO)
 
 
Post #: 14
 
 Re: Downloading a file - 6/10/2005 7:12:48 AM   
  Snipah


Posts: 1341
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
Yo, TNO, did the code from EricPhelps.com help? 'cause some sites (like i.e. GeoCities) have it blocked that may be downloaded by i.e. Forums and other other downloaders...that may thru their .htaccess.....so i won't work with all URLz

(in reply to TNO)
 
 
Post #: 15
 
 Re: Downloading a file - 6/11/2005 5:19:38 PM   
  TNO


Posts: 1064
Score: 10
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
I don't remember where it came from, I was searching alot of places.
I thought that htaccess rules might have limited the script same with <META> tags. Its probably easier to create an instance of IE and browse to the site and download with SendKey.

(in reply to TNO)
 
 
Post #: 16
 
 Re: Downloading a file - 6/12/2005 2:38:39 PM   
  atu

 

Posts: 33
Score: 0
Joined: 6/1/2005
From:
Status: offline
Will all due respect you guys inspite of solving my problem , arguing with each other.I said please make a web page for me which includes the above written code for downloading a file from internet without prompting a user.I have tried it hell of times but its not working.Surely i have made some mistakes because of which its not working so if you can solve my problem it wouldn't cost you anything.Please do help
Thanks

(in reply to TNO)
 
 
Post #: 17
 
 Re: Downloading a file - 6/13/2005 3:52:07 PM   
  TNO


Posts: 1064
Score: 10
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
"downloading a file from internet without prompting a user"

The code I've given so far should be sufficient. If you are trying to silently download some questionable type of file I won't give you any help. The only thing I'll tell you is to convince your "clients" to lower their browser security settings for a perfect stranger (you). I might also give you some help if you can convince me that:
#1) its for a legitimate reason. and
#2) you put some effort into it and show me what you've come up with.


(This is the 2nd post I've seen like this in 20 minutes.......)[V]

(in reply to TNO)
 
 
Post #: 18
 
 Re: Downloading a file - 6/15/2005 8:31:09 AM   
  DragonMasterXX5

 

Posts: 52
Score: 0
Joined: 6/13/2005
From: USA
Status: offline
Can you make it so that is can download MP3s?

(in reply to TNO)
 
 
Post #: 19
 
 Re: Downloading a file - 6/15/2005 10:58:42 AM   
  TNO


Posts: 1064
Score: 10
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
I haven't tested this but I believe that this would work on any file copied into the temporary folder.

(in reply to TNO)
 
 
Post #: 20
 
 
Page:   [1] 2   next >   >>
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Downloading a file Page: [1] 2   next >   >>
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts