VBscript download file from url

Updated: January 10, 2013

Ali Taheri


  1. Create a text file then save it as example.vbs (with vbs extension).
  2. Copy and paste the code below:  
    Set args = WScript.Arguments
    '// you can get url via parameter like line below
    '//Url = args.Item(0)
     Url = "/mypdf.pdf"
    dim xHttp: Set xHttp = createobject("Microsoft.XMLHTTP")
    dim bStrm: Set bStrm = createobject("Adodb.Stream")
    xHttp.Open "GET", Url, False
    with bStrm
        .type = 1 '//binary
        .write xHttp.responseBody
        .savetofile "d:\DownloladPdf.pdf", 2 '//overwrite
    end with
  3. Change the URL value. If you want to pass parameter you can just do it like this: example.vbs and uncomment Url = args.Item andremove Url = "/mypdf.pdf"


comments powered by Disqus

© 2017 - Ali Sheikh Taheri