js| Timing
To do the timing, the first thing we think about is to write a program ourselves and then deploy the program to win's scheduled task.
This program can be a simple batch processing dat file, or it can be a JS file. Of course, more complicated dll,exe can also be.
Considering the convenience, easy maintenance, I recommend the use of JS files.
Here is a simple JS sample file.
His function is: visit a page, if found this page abnormal restart the IIS service.
By deploying it to a scheduled task, you can monitor your Web site.
if (! Checkurl ())
{
WScript.Echo ("IISReset");
var s = new ActiveXObject ("Wscript.Shell");
S.run ("iisreset");
}
Else
{
WScript.Echo ("OK");
}
function Checkurl ()
{
Try
{
var xh=new activexobject ("Microsoft.XMLHTTP");
Xh.open ("Get", "http://localhost/quickstart/aspplus/doc/businessobjs.aspx", false);
Xh.send ("");
return xh.status = = 200;
}
catch (X)
{
return false;
}
}
The above use Microsoft.XMLHTTP if a site does not respond, he will always wait. This problem can be avoided by changing into msxml2.serverxmlhttp. Refer to the following function:
function Checkurl ()
{
Try
{
With this, you can set the timeout time without waiting.
var xmlserverhttp = new ActiveXObject ("Msxml2.serverxmlhttp");
var lresolve = 5 * 1000;
var lconnect = 5 * 1000;
var lsend = 15 * 1000;
var lreceive = 15 * 1000;
Xmlserverhttp.settimeouts (Lresolve, Lconnect, Lsend, lreceive);
Xmlserverhttp.open ("Get", "http://localhost/quickstart/aspplus/doc/businessobjs.aspx", false);
Xmlserverhttp.send ();
return xmlserverhttp.status = = 200;
}
catch (X)
{
return false;
}
}
If you want to access a page that requires authentication.
Please refer to:
Oxmlhttprequest.open (method, Url, Async, User, Password)