0

I copied this script from here but I'm not sure how to modify it to make it just call the url as a GET request - but I don't need it to write any file output based on the url's response.

script.vbs

sSrcUrl = "http://localhost:8080/trigger_url"
sDestFolder = "D:\script\"
sImageFile = "output.txt"
set oHTTP = WScript.CreateObject("MSXML2.ServerXMLHTTP")
oHTTP.open "GET", sSrcUrl, False
oHTTP.send ""
set oStream = createobject("adodb.stream")
Const adTypeBinary = 1
Const adSaveCreateOverWrite = 2
oStream.type = adTypeBinary
oStream.open
oStream.write oHTTP.responseBody
oStream.savetofile sDestFolder & sImageFile, adSaveCreateOverWrite
set oStream = nothing
set oHTTP = nothing

What's the minimum that this script would need to just ping the url?

Community
  • 1
  • 1
zippy
  • 981
  • 1
  • 6
  • 8
  • Your terminology is pretty far off, you cannot "ping" a URL, but if you want ti check that it exists, you could change the GET to a HEAD. – tripleee Oct 22 '11 at 15:33

1 Answers1

1

If this:

   Dim sSrcUrl : sSrcUrl   = "http://localhost:8080/trigger_url"
   Dim oHTTP   : Set oHTTP = WScript.CreateObject("MSXML2.ServerXMLHTTP")
   oHTTP.open "HEAD", sSrcUrl, False
  On Error Resume Next  
   oHTTP.send ""
   If 0 = Err.Number Then
      WScript.Echo oHTTP.Status, sSrcUrl
   Else
      WScript.Echo Err.Description
   End If  
  On Error GoTo 0  

gives you something like:

200 http://localhost:8080/trigger_url

all you have to read about/learn starting here is ".open", ".send", and ".Status".

Ekkehard.Horner
  • 38,498
  • 2
  • 45
  • 96