我尝试使用ActiveXobject
运行此批处理文件,但这仅适用于IE。我可以获得在Chrome / Firefox上运行它的解决方案吗?
答案 0 :(得分:0)
如果您正在开发Firefox扩展,则以下代码有效。它启动D:\ test.bat文件。
var file = null;
var process = null;
var args = [""];
// create an nsIFile for the executable
file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsIFile);
file.initWithPath("D:\\test.bat");
// create an nsIProcess
process = Components.classes["@mozilla.org/process/util;1"].createInstance(Components.interfaces.nsIProcess);
process.init(file);
// Launch the process
process.run(false , args, args.length);