Question:
how do I pass arguments to a batch file using javascript?
vahntasyo
2010-08-25 09:38:16 UTC
I have a batch file that accepts arguments, how do I pass the arguments from javascript or html if possible?
Three answers:
Base
2010-08-25 10:00:51 UTC




strCommand

String value indicating the command line you want to run. You must include any parameters you want to pass to the executable file.

For Example:

WshShell.run( '"fileName.bat" ' + arg1 + ' ' + arg2, 1, true );





intWindowStyle - Optional. Integer value indicating the appearance of the program's window. Note that not all programs make use of this information.



bWaitOnReturn - Optional. Boolean value indicating whether the script should wait for the program to finish executing before continuing to the next statement in your script.





Link for WshShell object: http://msdn.microsoft.com/en-us/library/d5fk67ky.aspx



Tek-Tips forum quetion on same topic: http://www.tek-tips.com/viewthread.cfm?qid=1226233&page=1



http://techrepublic.com.com/5208-11192-0.html?forumID=52&threadID=201017&messageID=2538160





You could also try opening cmd line directly from your script, and running commands.

WshShell.run "cmd /K CD C:\ & Dir"

The script opens a command window, changes to the path to C:\ , and executes the DIR command.
gonzaliz
2016-10-30 10:32:57 UTC
Passing Arguments To Batch File
rentschler
2016-10-22 05:19:22 UTC
that's accessible your subject is in simple terms that throughout the time of your String.format you're keeping apart parameters employing commas, while the batch report expects areas (and so is in all danger taking the commas as component to the parameters). try changing processInfo.Arguments = String.format("{0}, {a million}, {2}, {3}", ip, shared, pwd, person); to processInfo.Arguments = String.format("{0} {a million} {2} {3}", ip, shared, pwd, person);


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...