0

I have a VBScript file set to run on an old Windows XP machine dedicated to run scheduled processes. The script simply calls a URL. It doesn't have to do any any error correction (the web page handles all that). The script looks like this:

Sub SampleProcessor()
  On Error Resume Next
  Dim objRequest
  Dim URL
  Set objRequest = CreateObject("Microsoft.XMLHTTP")
  URL = "https://www.url.com/Processor.php"
  objRequest.Open "POST", URL, False
  objRequest.Send
  Set objRequest = Nothing
End Sub

Call SampleProcessor()

Now this script is scheduled to run every five minutes, 24 hours a day and has worked flawlessly for years.

I recently had to create a new process similar to this one.

I took the same .vbs file above, renamed it, changed the name of the function and the URL. saved it. put it in as a scheduled process. It will not run. I have verified both scripts are set to run under the same user. The URL works when entering it into a browser window on the same machine. To avoid any possible collision, the old function runs every 5 minutes starting at 7:00 pm and the new one runs every 5 minutes starting at 7:03 pm. Neither script takes more than 20-30 seconds to run typically. When called from the browser, the page produces no errors of any kind and runs correctly to completion every time.

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
  • Add Option Explicit to your first line, and, run the script interactively. The "Option Explicit" should help detect typos when you are renaming things. – Stephen Quan Apr 28 '17 at 04:39
  • Another thing, is the new URL, if it's using https, you may need to check the certificates are valid, and, if there are any corporate certificates (or self signed certificates) that need to be deployed, that you deploy to the logged in user. – Stephen Quan Apr 28 '17 at 04:42
  • a) Show the code that isn't working, not the code that does work. b) Remove `On Error Resume Next` while troubleshooting VBScript code. For further help on debugging scheduled tasks see [here](http://stackoverflow.com/a/41635982/1630171). – Ansgar Wiechers Apr 28 '17 at 10:32
  • You should also show the parameters used in the Scheduled Task. I suspect you have a problem with the path, possibly containing spaces or something like that – joehanna Apr 28 '17 at 13:54

2 Answers2

0

The first thing is to identify where the problem is. It could be related to the task scheduler, or with the vbs itself. So, a few things to check:

  1. event viewer for any errors.
  2. is the task scheduler showing success or failure? in case of the latter, paste the error here.
  3. use filesystemobect and write a file in certain parts of the script, that is a simple way for you to know where the script is quitting (in case it is being executed and failing) (kinda lame but works :))

If you can't spot the error, then export the scheduled tasks as xml and attach to this question. It might help on investigating the issue.

DAlvarenga
  • 36
  • 5
0

Thanks for the comments. I figured it out eventually. I visited the urls in a browser (Chrome) on the scheduled processor computer and it worked just fine... I also saved the files as .asp pages, put those on a web server and tested them and they worked.

Then I went back to the scheduled processor machine and opened the url in IE 8 - and one url worked, the other didn't.

The one that didn't is running on a machine using SNI to host multiple SSL sites on a single IP address. IE 8 doesn't support SNI, so it can't properly handle the https handshake... since this bit of code contains nothing even remotely sensitive - I just switched to http and it's working like a charm.

Hopefully, the budget gods will let me replace the old XP machine soon, but if not, anyone know how to get Microsoft.XMLHTTP to handle SNI?