Other recommendations returning value (or values) FROM JScript TO Batch? RRS feed

  • Question

  • What ways are there to return a value or multiple values FROM JScript TO DOS Batch?


    I have a couple of approaches for passing a single value, but I know none for passing multiple values.


    A) This one can only pass numbers into ERRORLEVEL. However, this is messing around with a Batch variable meant for Error handling, which rubs me the wrong way:


    Using DOS ERRORLEVEL to catch from JScript WScript.Quit:

    FROM Jscript: test.js



    TO Batch: test.cmd

                CScript test.js





    B) Another using the DOS for to run a specified command until a parameter is returned:


    Using DOS for command

    FROM Jscript: test.js



    TO Batch: test.cmd

                FOR /F %%var IN ('CScript test.js') DO SET RETURN_VALUE=%%var



    Are there other approaches that are better?



    Tuesday, November 11, 2008 8:54 AM