Click here to Skip to main content
15,890,378 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends I am trying to run this cron for email functianlity. The same code is working with another system.



C#
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 follow 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 receive the below error
VB
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.

D:\Projects\Cron\CronScript.js(1, 1) 
Microsoft JScript runtime error: '' is undefined



Please guide me where I am lacking, I am looking for this since long.
Posted
Updated 2-Apr-14 22:43pm
v2
Comments
Tom Marvolo Riddle 1-Apr-14 9:26am    
I'm not sure but i guess the directory is the problem.
localhost:51611.

Run another page of same project and replace the same directory and try it
Prasad Khandekar 1-Apr-14 10:38am    
Hello Manish,

Have you used notepad for creating the script? If yes then may be you have saved it using UTF-8 encoding. Try saving it without UTF-8 encoding.

Also try running cscript with /E:JScript switch.

Regards,
Manish Kumar Namdev 2-Apr-14 1:14am    
Hi I am using Visual Studio 2010 and created a .js file.
And I could not understand the "Also try running cscript with /E:JScript switch". Is that mean I should try like C:\Windows\System32>cscript.exe /D:\Projects\Cron\CronScript.js


Please explain me in the above query context
Prasad Khandekar 2-Apr-14 5:23am    
Open the file in notepad. Click on File Menu then Encoding And make sure that menu item named ANSI is checked. The save the file.

The command to run will be

cscript.exe /E:JScript D:\Projects\Cron\CronScript.js
Manish Kumar Namdev 3-Apr-14 4:57am    
Hi Prasad thanks to explain this...
yup! I got the meaning for cscript.exe "path for file" but this /E:Jscript has any special meaning or it is the directory?

1 solution

Hi friends,

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.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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900