how to run a multi-line command line or a .bat file in scripting

Post Reply
MercuryLamp
Newbie
Posts: 2
Joined: Sun Aug 14, 2022 6:39 am

how to run a multi-line command line or a .bat file in scripting

Post by MercuryLamp »

how to run a multi-line command line or a .bat file in scripting
has tried Process.execute(cmd1 & cmd2) failed
freddyp
Advanced member
Posts: 1008
Joined: Thu Feb 09, 2012 3:53 pm

Re: how to run a multi-line command line or a .bat file in scripting

Post by freddyp »

If the batch file is fixed

Code: Select all

var batchFile = "E:\\path\\to\\batchfile.bat";
var processOptions = ["cmd","/C",batchFile];
var result = Process.execute(processOptions);
Not tested! If the contents are variable you will have to write a temporary batch file of course.

Code: Select all

var batchFilePath = job.createPathWithName(job.getNameProper()+".bat";
I strongly advise against doing this in legacy scripting. It is just as easy to do this in Node.js. The package that I use for running external commands is execa (https://www.npmjs.com/package/execa).
MercuryLamp
Newbie
Posts: 2
Joined: Sun Aug 14, 2022 6:39 am

Re: how to run a multi-line command line or a .bat file in scripting

Post by MercuryLamp »

Yess.. thank you very much it is working :D
Post Reply