nsISupports
Last changed in Gecko 2.0 (Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1)Implemented by: @mozilla.org/process/util;1
. To create an instance, use:
var process = Components.classes["@mozilla.org/process/util;1"] .createInstance(Components.interfaces.nsIProcess);
void init(in nsIFile executable); |
void initWithPid(in unsigned long pid); Obsolete since Gecko 1.9.2 |
void kill(); |
void run(in boolean blocking, [array, size_is(count)] in string args, in unsigned long count); |
void runAsync([array, size_is(count)] in string args, in unsigned long count, [optional] in nsIObserver observer, [optional] in boolean holdWeak); |
void runw(in boolean blocking, [array, size_is(count)] in wstring args, in unsigned long count); |
void runwAsync([array, size_is(count)] in wstring args, in unsigned long count, [optional] in nsIObserver observer, [optional] in boolean holdWeak); |
Attribute | Type | Description |
exitValue |
long |
The value returned by the process upon exit. This is only valid after the process has exited. Read only. |
isRunning |
boolean |
true if the process is running, otherwise false . Only accurate if the process was run with blocking disabled. Read only. |
location |
|
The location of the executable file on disk. Read only. Gecko 1.9.1 note
This attribute is no longer implemented as of Gecko 1.9.1, and is removed entirely in Gecko 1.9.2.
|
pid |
unsigned long |
The process ID of the process. This value is only available after the process has started; in addition, some platforms may not offer this value at all. Read only. |
processName |
string |
The name of the process. Read only. Gecko 1.9.1 note
This attribute is no longer implemented as of Gecko 1.9.1, and is removed entirely in Gecko 1.9.2.
|
processSignature |
unsigned long |
The process signature. Read only. Gecko 1.9.1 note
This attribute is no longer implemented as of Gecko 1.9.1, and is removed entirely in Gecko 1.9.2.
|
Initializes the nsIProcess
with the specified executable file. Once initialized, you can start the process executing by calling run()
.
void init( in nsIFile executable );
executable
nsIFile
executable file to be represented by the nsIProcess
object.Initializes the nsIProcess
to represent an existing process, given that process's ID.
void initWithPid( in unsigned long pid );
pid
Immediately terminates the process represented by the nsIProcess
object. This only works if the process was run without blocking enabled.
void kill();
None.
Starts executing the process.
void run( in boolean blocking, [array, size_is(count)] in string args, in unsigned long count );
blocking
true
, this method will block until the process terminates; if false
, the method returns immediately.args
count
arguments, using the native character set, to be passed to the executable on its command line.count
args
array.Asynchronously runs the process with which the object was initialized, optionally calling an observer when the process finishes running.
void runAsync( [array, size_is(count)] in string args, in unsigned long count, in nsIObserver observer, Optional in boolean holdWeak Optional );
args
count
entries.count
args
array.observer
OptionalnsIProcess
instance as the subject and "process-finished" or "process-failed" as the topic. The observer will be notified on the main thread.holdWeak
Optionaltrue
, a weak reference is used to hold the observer.Executes the file this object was initialized with.
void runw( in boolean blocking, [array, size_is(count)] in wstring args, in unsigned long count );
blocking
true
, this method will block until the process terminates; if false
, the method returns immediately.args
count
arguments, using UTF-16, to be passed to the executable on its command line.count
args
array.Asynchronously runs the process with which the object was initialized, optionally calling an observer when the process finishes running.
void runwAsync( [array, size_is(count)] in wstring args, in unsigned long count, in nsIObserver observer, Optional in boolean holdWeak Optional );
args
count
entries.count
args
array.observer
OptionalnsIProcess
instance as the subject and "process-finished" or "process-failed" as the topic. The observer will be notified on the main thread.holdWeak
Optionaltrue
, a weak reference is used to hold the observer.// create an nsIFile for the executable var file = Components.classes["@mozilla.org/file/local;1"] .createInstance(Components.interfaces.nsIFile); file.initWithPath("c:\\myapp.exe"); // create an nsIProcess var process = Components.classes["@mozilla.org/process/util;1"] .createInstance(Components.interfaces.nsIProcess); process.init(file); // Run the process. // If first param is true, calling thread will be blocked until // called process terminates. // Second and third params are used to pass command-line arguments // to the process. var args = ["argument1", "argument2"]; process.run(false, args, args.length);
nsIFile
nsIProcess2
Obsolete since Gecko 1.9.2