在命令行上通过 cscript 将参数传递给 javascript

发布于 2024-09-06 01:38:58 字数 177 浏览 1 评论 0原文

我有一个小型命令行 JScript 例程,通常在 Windows 中使用 cscript 从命令行运行。我希望能够按照以下方式传递论据:

%:>cscript doSomethingToFile.js FileInQuestion.txt

对如何做到这一点有任何见解吗?

I have a small command line JScript routine that I usually run from the command line using cscript in Windows. I'd like to be able to pass in arguments hopefully along the lines of...

%:>cscript doSomethingToFile.js FileInQuestion.txt

Any insight on how to do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ζ澈沫 2024-09-13 01:38:59

来自 Bernard Marx

  1. 创建此 JScript 文件,将其保存在 C 目录中,(作为 xx.js)

xx.js

alert = function(s){WScript.Echo(s)}

var arg = WScript.arguments(0)
alert(arg.toUpperCase() + " now upper case")
...
  1. 打开命令提示符,然后键入

(假设在 C:> 提示符下):

C:\> windows\wscript.exe xx.js "apples and bananas"

From Bernard Marx

  1. Create this JScript file, save it in C directory, (as xx.js)

xx.js

alert = function(s){WScript.Echo(s)}

var arg = WScript.arguments(0)
alert(arg.toUpperCase() + " now upper case")
...
  1. Open the command prompt, and type

(assuming at C:> prompt):

C:\> windows\wscript.exe xx.js "apples and bananas"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文