lazy into software re-use, surely I don't
have to write a whole lot of code someone's already written?
Go to http://jslib.mozdev.org/
Files and Processes
How do I run/spawn/execute an external program or process?
You can use the 'spawn' method of the
jslib FileUtils class.
Unfortunately the spawn method in jslib is broken
(prior to around May 22, 2002) if you're using a
version of Mozilla which has the spawn method removed from the
nsIFile interface (not sure when this happened). You can use a
workaround instead. To see it working check out an
example that features a button that executes
a program when clicked. I worked this into a minor patch for jslib
which was accepted and and is included in build 571 onwards (dated 21 May 2002).
The example is for Linux but you can change it to use notepad.exe
on Windows or something else on the Mac (although I'm not sure how well
it works on the Mac). This brings up the issue of cross-platform compatibility:
if it's possible to avoid running an external program it's a preferable
solution. It would be good if it was possible to run an arbitrary helper
If you're looking on the web for more information note that the nsIFile
interface used to feature a spawn method but this was removed
and it would appear the methods of the nsIProcess interface should
be used instead.
© Copyright rancidbacon.com 2001-2003. All rights reserved.