0

This is what I like to achieve inside Window Server:

  1. Call external URL: https://www.example.com
  2. Save the result of that URL in a variable.
  3. If the variable is XXX kill a process inside the Window Server.

What is the best way to manage it inside Windows Servers? and do you have an example of similar code?

Thanks

Noamway
  • 153
  • 2
  • 8

1 Answers1

0

I once faced a similar task. Here is part of the resulting vbs-script, wich is called by the taskplaner every hour. It sends a GET-request to a site and processes the response.

To clarify the example; The body of the response is just a bunch of IDs, separated by semikolon (eg. 7;12;13;25)


Dim oRequest, oRegex, sResponse, aStats
Set oRequest = CreateObject("WinHttp.WinHttpRequest.5.1")
oRequest.Option(4) = 13056
oRequest.Open "GET", "https://example.com/svc/" & "stats.php" & "?pw=secret"
oRequest.Send

sResponse = oRequest.responseText
Set oRegex = CreateObject("VBScript.RegExp")
oRegex.Pattern =  "^[0-9]*(;[0-9]*)*$"

If oRegex.Test(sResponse) = True Then
    aStats = Split(sResponse, ";")
    For i = 0 To UBound(aStats) - 1
    ...

Set oRegex = Nothing
Set oRequest = Nothing