Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Download file trough batch  (Read 2542 times)

0 Members and 1 Guest are viewing this topic.

Blackberry

    Topic Starter


    Adviser
  • For those with wings, fly to your dreams.
    Download file trough batch
    « on: June 02, 2009, 12:46:09 PM »
    Hi there,
    is there any way I can download a file from a webserver trough batch (under winxp/vista)
    I made a batch file that creates the following vbscript (and launches it):
    End Sub

    The script works like a charm for files less then 50 kb, but I want to download a file that is 450 kb.

    Can anyone please help me

    P.S. Installing external command line tools isn't an option, cause I can't install anything else
    « Last Edit: June 12, 2009, 11:26:01 AM by Blackberry »
    Everybody knows you can't click here. But I know you will try it :)

    DaveLembke



      Sage
    • Thanked: 662
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 10
    Re: Download file trough batch
    « Reply #1 on: June 02, 2009, 02:00:00 PM »
    You appear to be hitting a maximum buffer size that is more like 64k instead of 50k. You will likely have to write the 64k buffer prior to reaching 64k and then grab the other 63 or 64 k and perform another write appended to the end of file of the first write until the entire file is transferred. Not sure if this can be done and keep the handshake of the download or if the delay in writing will error that possibility out.

    - OR - find a way to use a buffer other than the default without the 64k limit. In a PERL script on google a person stated that they changed from 64k to 2GB Buffer by switching between Win32::Textfield to Win32::RichEdit. This wont help you directly with your code, but sounds like the same issue, but a different language. ** For 2GB obviously you need resources to support that.

    Other possibility is a limitation in the dos-shell buffer of windows that I didnt dig up any info on.

    Windows caches downloads prior to writing to the hard drive so maybe there is an API call... although if you are going into API territory its further away from a batch than you probably want to be since you wanted to do this in batch.


    BC_Programmer


      Mastermind
    • Typing is no substitute for thinking.
    • Thanked: 1140
      • Yes
      • Yes
      • BC-Programming.com
    • Certifications: List
    • Computer: Specs
    • Experience: Beginner
    • OS: Windows 11
    Re: Download file trough batch
    « Reply #2 on: June 02, 2009, 02:05:37 PM »
    wait a minute- ever since VB moved from 16-bit to 32-bit and dumped HLSTR's in favour of BSTR's it has had a maximum string size of 2GB...

    Also- Why not write out the entire responsebody? I'm not sure exactly what the loop is trying to do- but couldn't you simply do:


    Code: [Select]
    objfile.write objHTTP.ResponseBody


    and, if it's converting to or from unicode you could use the StrConv() function.


    Also- what exactly happens with files that are larger then 50K... (or 64K)
    I was trying to dereference Null Pointers before it was cool.

    Blackberry

      Topic Starter


      Adviser
    • For those with wings, fly to your dreams.
      Re: Download file trough batch
      « Reply #3 on: June 02, 2009, 02:33:40 PM »
      wait a minute- ever since VB moved from 16-bit to 32-bit and dumped HLSTR's in favour of BSTR's it has had a maximum string size of 2GB...

      Also- Why not write out the entire responsebody? I'm not sure exactly what the loop is trying to do- but couldn't you simply do:


      Code: [Select]
      objfile.write objHTTP.ResponseBody


      and, if it's converting to or from unicode you could use the StrConv() function.


      Also- what exactly happens with files that are larger then 50K... (or 64K)



      Thank you for your responses. After looking a long time i have found the following script which works perfectly, but I only have one problem. It promps with an useless textbox to say where the file is saved. This ins't really user-friendly because the user doesn't need to be bothered which such information imo. Does anyone now how to avoid the message box?

      Thanks in advance

      script:
      End Function
      « Last Edit: June 12, 2009, 11:25:44 AM by Blackberry »
      Everybody knows you can't click here. But I know you will try it :)

      devcom



        Apprentice

        Thanked: 37
        Re: Download file trough batch
        « Reply #4 on: June 02, 2009, 02:58:10 PM »
        you can use wget too
        Download: Choice.exe

        BC_Programmer


          Mastermind
        • Typing is no substitute for thinking.
        • Thanked: 1140
          • Yes
          • Yes
          • BC-Programming.com
        • Certifications: List
        • Computer: Specs
        • Experience: Beginner
        • OS: Windows 11
        Re: Download file trough batch
        « Reply #5 on: June 02, 2009, 02:58:55 PM »
        you can use wget too


        except:

        Quote
        P.S. Installing external command line tools isn't an option, cause I can't install anything else
        I was trying to dereference Null Pointers before it was cool.