What I want to do
I want to daily ping/poke a URL to activate a action I have written in C#, and is running on a webserver. To do this I expected that I could use the task scheduler.
My setup
I have set up the scheduled tasks action to call this program:
C:\...\_resources\callurl.cmd"
Created from this code taken from this SO post
@if (@This==@IsBatch) @then
@echo off
rem **** batch zone *********************************************************
setlocal enableextensions disabledelayedexpansion
rem Batch file will delegate all the work to the script engine
if not "%~1"=="" (
wscript //E:JScript "%~dpnx0" %1
)
rem End of batch area. Ensure batch ends execution before reaching
rem javascript zone
exit /b
@end
// **** Javascript zone *****************************************************
// Instantiate the needed component to make url queries
var http = WScript.CreateObject('Msxml2.XMLHTTP.6.0');
// Retrieve the url parameter
var url = WScript.Arguments.Item(0)
// Make the request
http.open("POST", url, false);
http.send();
// All done. Exit
WScript.Quit(0);
I then add the following argument to the task
/c "http://localhost/Controller/ActionToInvoke?guid=SOME-GUID"
The idea to use "/c" I have from this question.
The useraccount used to run the task is SYSTEM
When I do this nothing happens. Sometimes i CMD windows pops up for a split second, sometimes nothing happens. In both cases I can't see my action being hit (debugging the application and have set a breakpoint at the entry point)
Running it in CMD
If I open up my command promt, and run the command like this
callurl.cmd "http://localhost/Controller/ActionToInvoke?guid=SOME-GUID"
there is no problem. Here callurl.cmd does what I expect it to do, it calls my action.
What can I be doing wrong? Is there something here that I don't see?