Results 1 to 9 of 9

Thread: Download a file from a Password Protected server

  1. #1
    j2k
    Guest

    Question Download a file from a Password Protected server

    Hi,

    How can I download a file from a web server that is password protected? I know the Username and Password, and I can log in and download the file via a web browser but I need to download the file via a Visual Basic application. I don't know how/where to enter the code that tells it the username and password to provide...... PLEASE HELP

  2. #2
    j2k
    Guest
    *bump*

    Surely someone must know how to do it

  3. #3
    Hyperactive Member Jason Badon's Avatar
    Join Date
    Feb 2001
    Location
    Colorado
    Posts
    329
    check out this post by smalig
    http://www.vbforums.com/showthread.p...threadid=91105

    change his code to this

    VB Code:
    1. Screen.MousePointer = vbHourglass
    2.  
    3. Inet1.URL = "ftp://ftp.myhost.com"
    4. Inet1.UserName = "myuser"
    5. Inet1.Password = "mypass"
    6. Inet1.Protocol = icFTP
    7. Inet1.Execute Inet1.URL, "get /myfolder/myfile.txt c:\myfile.txt "
    8.  
    9. Do While Inet1.StillExecuting
    10. DoEvents
    11. Loop
    12.  
    13. Screen.MousePointer = vbDefault

    hope this helps

  4. #4
    j2k
    Guest
    Thanks for that but I need it for a HTTP url not an FTP one.. the home page for the server (example: http://www.mydomain.com) isn't password protected, but http://www.mydomain.com/visualbasic/ is. I need to be able to log in using Visual Basic, go to that directory, enter the required username and password, and download a file (called secret.frm).

    Any help is greatly appreciated.

  5. #5
    Junior Member
    Join Date
    Jun 2001
    Posts
    16
    it should be the same with HTTP as FTP, only change

    VB Code:
    1. Inet1.Protocol = icFTP

    to

    VB Code:
    1. Inet1.Protocol = icHTTP

    try that, I haven't done it before, but it seems logical
    Sevensins

  6. #6
    j2k
    Guest
    Thanks for that.. Tried it, no luck though

  7. #7
    j2k
    Guest
    Is there another control that might work instead of Inet? I can't get Inet to work

  8. #8
    Addicted Member Stephen Bazemore's Avatar
    Join Date
    Aug 2000
    Location
    North Carolina
    Posts
    158
    Try this: "Dunno if it will work or not, but it should."

    Code:
    Screen.MousePointer = vbHourglass 
    
    Inet1.URL = "http://username:[email protected]" 
    'Inet1.UserName = "myuser" 
    'Inet1.Password = "mypass" 
    'Inet1.Protocol = icFTP 
    Inet1.Execute Inet1.URL, "get /myfolder/myfile.txt c:\myfile.txt " 
    
    Do While Inet1.StillExecuting 
    DoEvents 
    Loop 
    
    Screen.MousePointer = vbDefault
    I dont think you should need the three lines I commented out.
    If that doesn't work maybe try
    Code:
    Inet1.URL = "http://username:[email protected]/myfolder/myfile.txt"
    Hope that helps.
    Stephen Bazemore
    Email:[email protected]

  9. #9
    j2k
    Guest
    It worked! Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width