user303644
user303644

Reputation: 43

Why does this VBS scheduled task (to call a URL) not work in Windows Server 2008?

This same script worked in older server OS environments, and even on my desktop; and allows me to kick off a nightly process on my website's URL. It simply will not execute the URL in my Windows Server 2008 environment.

I'm baffled as to why the task claims to have completed successfully, yet the script never reaches the URL.

Call LogEntry()

Sub LogEntry()

    'Force the script to finish on an error.
    On Error Resume Next

    'Declare variables
    Dim objRequest
    Dim URL

    Set objRequest = CreateObject("MSXML2.ServerXMLHTTP")

    'Put together the URL link appending the Variables.
    URL = "http://myURL/AutorunNightlyTasks.aspx"

    'Open the HTTP request and pass the URL to the objRequest object
    objRequest.open "GET", URL, False

    'Send the HTML Request
    objRequest.send()

    'Set the object to nothing
    Set objRequest = Nothing

End Sub

Upvotes: 2

Views: 1819

Answers (1)

Michel de Ruiter
Michel de Ruiter

Reputation: 7954

In the batch file, add output redirection to be able to catch output as well as errors:

cscript.exe //Nologo yourVBS.vbs > "%TEMP%output.txt" 2>> "%TEMP%\errors.txt"

And remove the On Error Resume Next as commented by @Helen, or errors are just ignored.

Upvotes: 1

Related Questions