Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I am working on a javascript(.js) job file which needs to be run through cmd. It has some switch case inside it to take parameter from CMD

when i am trying to run this job through cmd it is executing the default case eachtime not the case which i want to execute.

What I have tried:

I am running it through the below command

F:\Inet\root\eService\webs\UAT\Batch\Scripts CScript abc.js "kickoff"

where abc is the script name and kickoff i want to pass as the parameter.
Posted
Updated 20-Jun-16 21:49pm

1 solution

First of all, it's all not related to CMD.exe. You should have said "command line". CMD.exe is a command interpreter, which you may or may not need to use. This is not a tool to run an application with some command line. Anything else can do it.

As soon as you forget CMD.exe, I can tell you what exactly can work as a batch-like file started in directly, in just a click, without having to specify SCript application. This is an XML-based WSF file with one or more scripts embedded in it. Here is the simplest file sample:
HTML
<job>
<script language="JScript">
  WSH.echo("Hello world! (From JavaScript)");
</script>
</job>

Please see: Using Windows Script Files (.wsf).

When you just click on such file, without any command line, the script will run.

I would also note that this technology is quite old and was majorly superseded by PowerShell. At the same time, WSF has some great benefits: it does not require any installation and tuning, in big contrast to PowerShell. At the same time, scripting is much more reasonable and maintainable that old batch files (which also have been improved since NT).

—SA
 
Share this answer
 
v2
Comments
TarunShrivastav 21-Jun-16 5:58am    
Thanks for correcting me.But i cant modify that file i just have to run that .js file through command prompt
Sergey Alexandrovich Kryukov 21-Jun-16 9:46am    
Sure. But does my answer give you a solution?
—SA

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