我想在我的firefox扩展javascript文件中运行本地exe,但ActiveXObject(“WScript.Shell”)在IE中工作正常,而不是在FF中,如何在firefox中的js中运行本地exe。
答案 0 :(得分:9)
由于您已明确要求提供.exe,因此您可以使用nsILocalFile.launch()
:
https://developer.mozilla.org/en/Code_snippets/Running_applications
var file = Components.classes["@mozilla.org/file/local;1"]
.createInstance(Components.interfaces.nsILocalFile);
file.initWithPath("c:\\myapp.exe");
file.launch();
如果您想跨平台进行,请查看nsIProcess
答案 1 :(得分:0)
嗨所有那些试图在mozilla firefox中使用javascript调用exe的人。按照步骤..我可以从我的网站运行exe。
步骤1.在地址栏中输入“about:config”,并将“signed.applets.codebase-principal-support”设为true。 第2步。使用此代码。
<html>
<head>
</head>
<body>
<p/><input type="button" width="15" value="Run Exe" onclick="RunExe();"/></input></p>
<script type="text/javascript">
function RunExe()
{
alert("In fun RunExe()..");
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
alert("Done");
var exe = window.Components.classes['@mozilla.org/file/local;1'].createInstance(Components.interfaces.nsILocalFile);
exe.initWithPath("c:\\WINDOWS\\notepad.exe");
alert("exe");
var run = window.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");
}
</script>
</body>
</html>