I call the batch file from Javascript this way:
function runBatch(){ var exe = Components.classes['@mozilla.org/file/local;1'].createInstance(Components.interfaces.nsILocalFile); exe.initWithPath("C:\\test.bat"); var run = Components.classes['@mozilla.org/process/util;1'].createInstance(Components.interfaces.nsIProcess); run.init(exe); var parameters = ["hi"]; run.run(false, parameters,parameters.length); }
my test batch file:
echo on echo %1 pause exit
However, every time I call the batch file, the batch line is not displayed, as if I was just running the batch file from the desktop. How can I fix this and display the command line for the batch file?
Edit To be clear, the cmd.exe process is running - I see it in the taskbar. But the window does not appear. This fragment behaves similarly:
function runCmd(){ var exe = Components.classes['@mozilla.org/file/local;1'].createInstance(Components.interfaces.nsILocalFile); exe.initWithPath("C:\\WINDOWS\\system32\\cmd.exe"); var run = Components.classes['@mozilla.org/process/util;1'].createInstance(Components.interfaces.nsIProcess); run.init(exe); run.run(false, null,0); }
source share