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

Create script to copy *.pdf file from IE Link to Computer

I have a link :  http://www.ustreas.gov/offices/enforcement/ofac/sdn/t11sdn.pdf

I would like to create a script or batch file that will copy this pdf file to a location on my pc.
0
msammis
Asked:
msammis
1 Solution
 
SysExpertCommented:
Use auto-it the free scripting tool to do this.

auto-it Free scripting tool, keyboard macros  and compiled exe files

http://www.autoitscript.com/autoit3/


I hope this helps !
0
 
ghostdog74Commented:
there a variety of tools you can use beside autoit
1) wget for windows : http://gnuwin32.sourceforge.net/packages/wget.htm
depending on what you want, it could be as simple as
   c:\> wget http://www.ustreas.gov/offices/enforcement/ofac/sdn/t11sdn.pdf
 
2) curl for windows: http://fileforum.betanews.com/detail/cURL_for_Windows/966899018/1
   simple usage: c:\> curl  http://www.ustreas.gov/offices/enforcement/ofac/sdn/t11sdn.pdf
   check http://curl.haxx.se/docs/httpscripting.html for more info

3) if you can use Python. you can use the urllib2 module

import urllib2
url = "http://www.ustreas.gov/offices/enforcement/ofac/sdn/t11sdn.pdf"
open("t11sdn.pdf","w").write(urllib2.urlopen(url).read())

4) or you can use vbscript

    strFileURL = "http://www.ustreas.gov/offices/enforcement/ofac/sdn/t11sdn.pdf"
    strHDLocation = "c:\file.pdf"
    Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")    
    objXMLHTTP.open "GET", strFileURL, false
    objXMLHTTP.send()
    If objXMLHTTP.Status = 200 Then
      Set objADOStream = CreateObject("ADODB.Stream")
      objADOStream.Open
      objADOStream.Type = 1 'adTypeBinary
   
      objADOStream.Write objXMLHTTP.ResponseBody
      objADOStream.Position = 0    'Set the stream position to the start
     
      Set objFSO = Createobject("Scripting.FileSystemObject")
        If objFSO.Fileexists(strHDLocation) Then objFSO.DeleteFile strHDLocation
      Set objFSO = Nothing
     
      objADOStream.SaveToFile strHDLocation
      objADOStream.Close
      Set objADOStream = Nothing
    End if
   Set objXMLHTTP = Nothing
save as downloadFile.vbs and on command prompt: cscript /nologo downloadFile.vbs
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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