通过CMD运行.js作业 [英] Run .js job through CMD

查看:78
本文介绍了通过CMD运行.js作业的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理需要通过cmd运行的javascript(.js)作业文件。它里面有一些开关盒来接CMD参数



当我试图通过cmd运行这个工作时它每次都执行默认情况不是我的情况想要执行。



我尝试了什么:



我是通过以下命令运行它



F:\ Inet \root \ eService \webs \ UAT \ Batch \Scripts CScript abc.js启动



其中abc是脚本名称和我要作为参数传递的启动。

解决方案

首先,它与CMD.exe无关。你应该说命令行。 CMD.exe是一个命令解释器,您可能需要也可能不需要使用它。这不是使用某个命令行运行应用程序的工具。还有其他任何东西都可以做到。



一旦你忘记了CMD.exe,我就可以告诉你究竟什么可以作为一个类似批处理的文件直接启动,只需单击一下,无需指定SCript应用程序。这是一个基于XML的WSF文件,其中嵌入了一个或多个脚本。以下是最简单的文件示例:

 <   job  >  
< 脚本 语言 = JScript >
WSH.echo( Hello world!(来自JavaScript));
< / script >
< / job >



请参阅:使用Windows脚本文件(.wsf)



当你点击时这样的文件,没有任何命令行,脚本将运行。



我还会注意到这项技术很老,并且被PowerShell取代。与此同时,WSF有一些很大的好处:它不需要任何安装和调优,与PowerShell形成鲜明对比。与此同时,脚本编写比旧批处理文件(自NT以来也有所改进)更合理和可维护。



-SA

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.

解决方案

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:

<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


这篇关于通过CMD运行.js作业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆