How to run local exe in my Firefox extension?

I want to run local exe in my javascript firefox extension file, but ActiveXObject ("WScript.Shell") works fine in IE and not in FF, how to run local exe in js in firefox.

+4
source share
2 answers

Since you explicitly requested .exe, you can use 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(); 

If you want to make this cross-platform, you should study nsIProcess

+9
source

Hi to all those trying to call exe using javascript in mozilla firefox. Follow the instructions. I can run exe from my site.

Step 1. Enter "about: config" in the address bar and make "signed.applets.codebase-main-support" true. Step 2. Use this code.

 <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> 
0
source

Source: https://habr.com/ru/post/1304742/


All Articles