This page describes how to run other programs from your chrome JavaScript code, using Mozilla XPCOM interfaces. There are two ways to run programs.
Using nsIProcess
The recommended way is to use the nsIProcess
interface because it is crossplatform.
Using nsILocalFile.launch()
This method is not implemented on all platforms, especially not on Unix/Linux! See
nsILocalFile.launch()
for details and make sure that all your target platforms support this method!This method has the same effect as if you double-clicked the file, so for executable files—it will just run the file without any parameters.
For more information on nsIFile
/nsILocalFile
, see File I/O.
var file = Components.classes["@mozilla.org/file/local;1"] .createInstance(Components.interfaces.nsILocalFile); file.initWithPath("c:\\myapp.exe"); file.launch();
References
nsIProcess
nsILocalFile
- If you need to launch an executable bundled in your XPI, see Code snippets:File I/O#Getting your extension's folder.
- Launching an executable process from a web page