简体   繁体   中英

Executing .bat file using Java-script

Can someone help me in finding a solution for executing a batch file using java-script, i am currently working with nw.js and i tried couple of things which worked for .exe but not for .bat

var execFile = require 
('child_process').execFile, child;
child = execFile('C:\\WorkLog\\Software\\abc.exe', //works
//child = execFile('C:\\PDFRotation\\Run.bat', //not working 

A batch program is not really an executable, so you might have to use cmd.exe to invoke the batch file try something like:

var spawn = require('child-process').spawn;

spawn('cmd.exe', ['yourfile.bat']);

You don't actually execute a batch file. You execute cmd.exe and give it the batch file as a parameter.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM