0
我想通過javascript執行.exe文件,但不支持Mozilla中的ActiveX。在Mozilla Firefox中運行JavaScript代碼執行exe
,我讀了這是可以做到通過nslProcess
所以我嘗試了以下內容:
var exe = Components.classes['@mozilla.org/file/local;1'].createInstance(Components.interfaces.nsILocalFile);
exe.initWithPath("c:\\WINDOWS\\notepad.exe");
alert("exe");
var run = Components.classes['@mozilla.org/process/util;1'].createInstance(Components.interfaces.nsIProcess);
run.init(exe);
var parameters = [""];
run.run(false, parameters,parameters.length);
alert("in function RunBat");
}
而且得到了以下錯誤:
TypeError: Components.classes is undefined.
我做了什麼錯誤以及是否有任何替代品是否支持最新版本的Firefox?
P.S. 我有本地主機上的所有完全訪問權限。
更新:
我可以創建Firefox擴展其獲得inputExePath領域的價值在簡單的網頁,並在這條道路的exe運行?
看到這個答案http://stackoverflow.com/questions/21378058/why-components-classes-is-undefined – Girish
感謝上帝,這是不可能的。你試過的代碼只能在Firefox插件中運行。 – torvin