JSCRIPT - how to get the JSCRIPT to exit?

Posted on 2004-11-22
Last Modified: 2012-05-05
What is the syntax to get the JSCRIPT to exit ?

I tried this  and it works on Windows 2000 server but on Windows 2003 it just hangs ...

Wscript.Exit( 0)

Please advise what to do to get the script to exit on Windows 2003 machine.

Eagerly awaiting a response ..

Question by:sdesar
    LVL 7

    Expert Comment

    exit what?
    LVL 63

    Expert Comment

    That is not a valid Method call: Wscript.Exit( 0)

    You can Exit a loop, a function, a sub or a block of code.
    Therefore you should create a Sub for the main exution block and exit that sub block if you want to exit main statements block.


    Author Comment

    I have a JSCRIPT code - organise.js  the has this line

    </OrganiseUsers>   // this is the end of the script.

    In Windows 2002 when I run from the command line it exits fine -
    the end tag gets printted on the command line and I get the

    c:\> prompt.

    But in Windows 2003 Server the  organise.js script runs and it
    hangs at  -

    and NO c:\prompt.

    How can I get the csript to exit the cscript ?

    LVL 63

    Expert Comment

    This not a JavaScript statement:

    Show please the complete script.
    LVL 3

    Expert Comment

    Windows Script Host  

    Quit MethodSee Also
    Sleep Method

    Applies To: WScript Object
    Forces script execution to stop at any time.

    WScript object.
    Optional. Integer value returned as the process's exit code. If you do not include the intErrorCode parameter, no value is returned.
    The Quit method can return an optional error code. If the Quit method is the final instruction in your script (and you have no need to return a non-zero value), you can leave it out, and your script will end normally.

    The following JScript code snippet quits execution and returns an error code of 1:

    WScript.Quit (1);

    // This line of code is never executed.
    var i = 0;

    Again, MSDN2003:
    Windows Script Host  

    WScript Object Properties and MethodsProperties
    Arguments Property
    BuildVersion Property
    FullName Property
    Interactive Property
    Name Property
    Path Property
    ScriptFullName Property
    ScriptName Property
    StdErr Property
    StdIn Property
    StdOut Property
    Version Property

    ConnectObject Method
    CreateObject Method
    DisconnectObject Method
    Echo Method
    GetObject Method
    Quit Method
    Sleep Method

    as you see, there is no "Exit" method in the reference dated by 2003 :(
    LVL 3

    Expert Comment


    LVL 3

    Accepted Solution

    in plain english: WScript.Quit(1);

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
    This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now