13

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?

1

1 Answer 1

15

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"
Sign up to request clarification or add additional context in comments.

1 Comment

C:\Windows\wscript.exe? maybe C:\Windows\System32\wscript.exe C:\xx.js "apples and bananas"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.