Re: Executing a command line, stuck.
Doug Turner <[email protected]> Tue, 31 Dec 2002 13:21:00 -0800
| Newsgroups | gmane.comp.mozilla.devel.xpcom |
|---|---|
| Organization | Another Netscape Collabra Server User |
| Message-ID | <[email protected]> |
Baavgai wrote:
> Perhaps the example was bad enough that the point of the question was
> missed?
>
> I need to execute a command line. That is, a program and a series of
> arguments.
>
> examples would include:
> textpad.exe readme.txt
> zip -ex %mozdir%\profile c:\profile_back.zip
>
> A code snippet is what I'm hoping for here, I can read the online IDLs
> just fine. ;) I feel there must be someone who knows how to do this.
> By way of example, here is the code that can be used to execute a
> program with no arguments.
>
>
> function runProgram(fullPath) {
> var oLocalFile = getLocalFile();
> oLocalFile.initWithPath(fullPath);
> oLocalFile.launch();
> }
>
> function getLocalFile() {
> var className = "@mozilla.org/file/local;1";
> var svc = Components.interfaces.nsILocalFile;
> return Components.classes[className].createInstance(svc);
> }
>
>
> Thanks in advance for any help.
Here is an example in C++ on how to do this:
http://lxr.mozilla.org/seamonkey/source/uriloader/exthandler/win/nsOSHelperAppService.cpp#69
And a related call to getEnv in js:
http://lxr.mozilla.org/seamonkey/source/extensions/pref/autoconfig/src/prefcalls.js#210
Note that the interface nsIProcess isn't frozen and is subject to change.
I hope this helps. Happy New Year.
Doug Turner
[email protected]