Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

VBS Script Query

$
0
0

Hello,

I have this script below to download a file daily... only problem is the .zip file changes it's name slightly daily, so one day it could be 490 and the next it will go to 491 and so on...

Is there anything I can add to this script to either check a filename in a directory, and use that +1, or record the filename from the previous day and then specify the download link via that? Or someway of saying download the top link on this page... or last resort pop a box up to specify the revision of the number?

Ideally I want to run it as a scheduled task so don't want to have to interfere in anyway.

Source page the links are available on is http://www.sophos.com/downloads/ide/

  'Set your settings

    strFileURL = "http://downloads.sophos.com/downloads/ide/491_ides.zip"
    strHDLocation = "C:\dailydownloads\SAV32-IDES.zip"

   ' Fetch the file

    Set objXMLHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")

    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


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>