Question

var strURLs= new Array("http:// localhost: 51611/Cron/Email.aspx");
var webObj = WScript.CreateObject("MSXML2.ServerXMLHTTP");

var lResolve = 10 * 1000;
var lConnect = 10 * 1000;
var lSend = 60000 * 1000;
var lReceive = 60000 * 1000;

webObj.setTimeouts(lResolve, lConnect, lSend, lReceive);

for (var i = 0; i < strURLs.length; i++) {
    webObj.open("GET", strURLs[i], false);
    try {
        webObj.send();
        if (webObj.status != 200 || String(webObj.statusText).match(/Database is currently unavailable/gi) != null) {

        }
    }
    catch (e) {
    }
}

I am following the steps:
Step1: Run My visual studio project at localhost
Step2: Open the command prompt
Step3: Run the following command
C:\Windows\System32>cscript.exe "D:\Projects\Cron\CronScript.js"

I checked the code at online validator JLint
enter image description here After removing the whole if condition enter image description here

I am still receiving an error while compling

Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.

D:\Projects\Cron\CronScript.js(1, 8) Microsoft JScript compilation error: Expected ';' 

Please guide me where I am lacking I am looking it for long and posting here.

Was it helpful?

Solution

I got the solution for the issue and it is working fine properly.

Well I am using Visual Studio 2010 Project for my web application.   
So when I create any new page it contains 3 files Default.aspx, Default.aspx.cs,   
Default.aspx.designer.cs   
But when I choose New Website then I get only Default.aspx and Default.aspx.cs.

The same Cron code(javascript) mentioned above working fine for one of my colleague's and he is using Visual Studio 2010 Website.

I copied the same file(without the designer.cs file) with the same code in-fact same letter,      
    and add in my project and it worked.

Well my Cron motive has been accomplished but I am still confused why it didn't work for me in Project as it is working in Website template. Then I scheduled the cscript.exe to run this .js file in Windows Task Scheduler.

Please comment and guide us why it was not working and it worked in the same project but with a different.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top