Provides access to local and remote processes and enables you to start and stop local system processes.
The following example populates a StartInfo with the file to execute, the action performed on it and whether it should displays a user interface. For additional examples, refer to the reference pages for properties of the ProcessStartInfo class.
Classes | |
| class | error_data_received_event |
| Represents a process error data received event. More... | |
| class | exit_event |
| Represents a process exit event. More... | |
| class | output_data_received_event |
| Represents a process output data received event. More... | |
Constructors | |
| process () | |
| Initializes a new instance of the xtd::diagnostics::process class. More... | |
Properties | |
| int32 | base_priority () const |
| Gets the base priority xof the associated process. More... | |
| bool | enable_raising_events () const |
| Gets whether the xtd::diagnostics::process::exited event should be raised when the process terminates. More... | |
| process & | enable_raising_events (bool value) |
| Sets whether the xtd::diagnostics::process::exited event should be raised when the process terminates. More... | |
| int32 | exit_code () const |
| Gets the value that the associated process specified when it terminated. More... | |
| xtd::date_time | exit_time () const |
| Gets the time that the associated process exited. More... | |
| intptr | handle () const |
| Gets the native handle of the associated process. More... | |
| bool | has_exited () const |
| Gets a value indicating whether the associated process has been terminated. More... | |
| int32 | id () const |
| Gets the unique identifier for the associated process. More... | |
| ustring | machine_name () const |
| Gets the name of the computer the associated process is running on. More... | |
| xtd::diagnostics::process_priority_class | priority_class () const |
| Gets the overall priority category for the associated process. More... | |
| process & | priority_class (xtd::diagnostics::process_priority_class value) |
| Sets the overall priority category for the associated process. More... | |
| ustring | process_name () const |
| Gets the name of the process. More... | |
| std::istream & | standard_error () |
| Gets a stream used to read the error output of the application. More... | |
| std::ostream & | standard_input () |
| Gets a stream used to write the input of the application. More... | |
| std::istream & | standard_output () |
| Gets a stream used to read the textual output of the application. More... | |
| const xtd::diagnostics::process_start_info & | start_info () const |
| Gets the properties to pass to the xtd::diagnostics::process::start() method of the xtd::diagnostics::process. More... | |
| xtd::diagnostics::process_start_info & | start_info () |
| Gets the properties to pass to the xtd::diagnostics::process::start() method of the xtd::diagnostics::process. More... | |
| process & | start_info (const xtd::diagnostics::process_start_info &value) |
| Sets the properties to pass to the xtd::diagnostics::process::start() method of the xtd::diagnostics::process. More... | |
| xtd::date_time | start_time () const |
| Gets the time that the associated process was started. More... | |
Methods | |
| void | close () |
| Frees all the resources that are associated with this component. More... | |
| void | kill () |
| Immediately stops the associated process. More... | |
| bool | start () |
| Starts (or reuses) the process resource that is specified by the xtd::diagnostics::process::start_info property of this Process component and associates it with the component. More... | |
| process & | wait_for_exit () |
| Instructs the xtd::diagnostics::process component to wait indefinitely for the associated process to exit. More... | |
| process & | wait_for_exit (int32 milliseconds) |
| Instructs the Process component to wait the specified number of milliseconds for the associated process to exit. More... | |
| static process | start (const xtd::diagnostics::process_start_info &start_info) |
| Starts the process resource that is specified by the parameter containing process start information (for example, the file name of the process to start) and associates the resource with a new xtd::diagnostics::process component. More... | |
| static process | start (const ustring &file_name) |
| Starts a process resource by specifying the name of a document or application file and associates the resource with a new Process component. More... | |
| static process | start (const ustring &file_name, const ustring &arguments) |
| Starts a process resource by specifying the name of an application and a set of command-line arguments, and associates the resource with a new xtd::diagnostics::process component. More... | |
Events | |
| error_data_received_event | error_data_received |
| Occurs when an application writes to its redirected xtd::diagnostics::process::standard_error stream. More... | |
| exit_event | exited |
| Occurs when a process exits. More... | |
| output_data_received_event | output_data_received |
| Occurs each time an application writes a line to its redirected xtd::diagnostics::process::standard_output stream. More... | |
Protected methods | |
| virtual void | on_exited () |
| Raises the xtd::diagnostics::process::exited event. More... | |
Additional Inherited Members | |
Public Member Functions inherited from xtd::object | |
| object ()=default | |
| Create a new instance of the ultimate base class object. More... | |
| bool | equals (const object &obj) const noexcept |
| Determines whether the specified object is equal to the current object. More... | |
| virtual size_t | get_hash_code () const noexcept |
| Serves as a hash function for a particular type. More... | |
| virtual type_object | get_type () const noexcept |
| Gets the type of the current instance. More... | |
| template<typename object_t > | |
| std::unique_ptr< object_t > | memberwise_clone () const noexcept |
| Creates a shallow copy of the current object. More... | |
| virtual xtd::ustring | to_string () const noexcept |
| Returns a sxd::ustring that represents the current object. More... | |
Static Public Member Functions inherited from xtd::object | |
| static bool | equals (const object &object_a, const object &object_b) noexcept |
| Determines whether the specified object instances are considered equal. More... | |
| static bool | reference_equals (const object &object_a, const object &object_b) noexcept |
| Determines whether the specified object instances are the same instance. More... | |
| xtd::diagnostics::process::process | ( | ) |
Initializes a new instance of the xtd::diagnostics::process class.
| int32 xtd::diagnostics::process::base_priority | ( | ) | const |
Gets the base priority xof the associated process.
| xtd::invalid_operation_exception | There is no process associated with this xtd::diagnostics::process object. |
| Windows base_priority | macOS base_priority | linux base_priority | priority_class |
|---|---|---|---|
| 4 | PRIO_MIN (-20) | PRIO_MIN (-20) | xtd::diagnostics::process_priority_class::idle |
| 6 | PRIO_MIN + (PRIO_MAX - PRIO_MIN) / 4 (-10) | PRIO_MIN + (PRIO_MAX - PRIO_MIN) / 4 (-10) | xtd::diagnostics::process_priority_class::below_normal |
| 8 | PRIO_MIN + (PRIO_MAX - PRIO_MIN)/2 (0) | PRIO_MIN + (PRIO_MAX - PRIO_MIN)/2 (0) | xtd::diagnostics::process_priority_class::normal |
| 10 | PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 4 (10) | PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 4 (10) | xtd::diagnostics::process_priority_class::above_normal |
| 13 | PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 8 (15) | PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 8 (15) | xtd::diagnostics::process_priority_class::high |
| 24 | PRIO_MAX (20) | PRIO_MAX (20) | xtd::diagnostics::process_priority_class::real_time |
| void xtd::diagnostics::process::close | ( | ) |
Frees all the resources that are associated with this component.
| xtd::invalid_operation_exception | There is no process associated with this xtd::diagnostics::process object. |
| bool xtd::diagnostics::process::enable_raising_events | ( | ) | const |
Gets whether the xtd::diagnostics::process::exited event should be raised when the process terminates.
| process& xtd::diagnostics::process::enable_raising_events | ( | bool | value | ) |
Sets whether the xtd::diagnostics::process::exited event should be raised when the process terminates.
| value | true if the xtd::diagnostics::process::exited event should be raised when the associated process is terminated (through either an exit or a call to xtd::diagnostics::process::kill()); otherwise, false. The default is false. Note that the xtd::diagnostics::process::exited event is raised even if the value of xtd::diagnostics::process::enable_raising_events is false when the process exits during or before the user performs a xtd::diagnostics::process::has_exited check. |
| int32 xtd::diagnostics::process::exit_code | ( | ) | const |
Gets the value that the associated process specified when it terminated.
| xtd::invalid_operation_exception | The process has not exited. -or- The process xtd::diagnostics::process::handle is not valid. |
| xtd::not_supported_exception | You are trying to access the xtd::diagnostics::process::exit_code property for a process that is running on a remote computer. This property is available only for processes that are running on the local computer. |
| xtd::date_time xtd::diagnostics::process::exit_time | ( | ) | const |
Gets the time that the associated process exited.
| xtd::not_supported_exception | You are trying to access the xtd::diagnostics::process::exit_time property for a process that is running on a remote computer. This property is available only for processes that are running on the local computer. |
| intptr xtd::diagnostics::process::handle | ( | ) | const |
Gets the native handle of the associated process.
| xtd::invalid_operation_exception | The process has not been started or has exited. The xtd::diagnostics::process::handle property cannot be read because there is no process associated with this xtd::diagnostics::process instance. -or- The xtd::diagnostics::process instance has been attached to a running process but you do not have the necessary permissions to get a handle with full access rights. |
| xtd::not_supported_exception | You are trying to access the xtd::diagnostics::process::handle property for a process that is running on a remote computer. This property is available only for processes that are running on the local computer. |
| bool xtd::diagnostics::process::has_exited | ( | ) | const |
Gets a value indicating whether the associated process has been terminated.
| xtd::invalid_operation_exception | There is no process associated with the object. |
| xtd::not_supported_exception | You are trying to access the xtd::diagnostics::process::has_exited property for a process that is running on a remote computer. This property is available only for processes that are running on the local computer. |
| int32 xtd::diagnostics::process::id | ( | ) | const |
Gets the unique identifier for the associated process.
| xtd::invalid_operation_exception | The process's Id property has not been set. |
| void xtd::diagnostics::process::kill | ( | ) |
Immediately stops the associated process.
| xtd::invalid_operation_exception | There is no process associated with this xtd::diagnostics::process object. |
| ustring xtd::diagnostics::process::machine_name | ( | ) | const |
Gets the name of the computer the associated process is running on.
| xtd::invalid_operation_exception | There is no process associated with this xtd::diagnostics::process object. |
|
protectedvirtual |
Raises the xtd::diagnostics::process::exited event.
| xtd::diagnostics::process_priority_class xtd::diagnostics::process::priority_class | ( | ) | const |
Gets the overall priority category for the associated process.
| xtd::invalid_operation_exception | There is no process associated with this xtd::diagnostics::process object. |
| Windows base_priority | macOS base_priority | linux base_priority | priority_class |
|---|---|---|---|
| 4 | PRIO_MIN (-20) | PRIO_MIN (-20) | xtd::diagnostics::process_priority_class::idle |
| 6 | PRIO_MIN + (PRIO_MAX - PRIO_MIN) / 4 (-10) | PRIO_MIN + (PRIO_MAX - PRIO_MIN) / 4 (-10) | xtd::diagnostics::process_priority_class::below_normal |
| 8 | PRIO_MIN + (PRIO_MAX - PRIO_MIN)/2 (0) | PRIO_MIN + (PRIO_MAX - PRIO_MIN)/2 (0) | xtd::diagnostics::process_priority_class::normal |
| 10 | PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 4 (10) | PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 4 (10) | xtd::diagnostics::process_priority_class::above_normal |
| 13 | PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 8 (15) | PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 8 (15) | xtd::diagnostics::process_priority_class::high |
| 24 | PRIO_MAX (20) | PRIO_MAX (20) | xtd::diagnostics::process_priority_class::real_time |
| process& xtd::diagnostics::process::priority_class | ( | xtd::diagnostics::process_priority_class | value | ) |
Sets the overall priority category for the associated process.
| value | The priority category for the associated process, from which the xtd::diagnostics::process::base_priority of the process is calculated. |
| xtd::invalid_operation_exception | There is no process associated with this xtd::diagnostics::process object. |
| Windows base_priority | macOS base_priority | linux base_priority | priority_class |
|---|---|---|---|
| 4 | PRIO_MIN (-20) | PRIO_MIN (-20) | xtd::diagnostics::process_priority_class::idle |
| 6 | PRIO_MIN + (PRIO_MAX - PRIO_MIN) / 4 (-10) | PRIO_MIN + (PRIO_MAX - PRIO_MIN) / 4 (-10) | xtd::diagnostics::process_priority_class::below_normal |
| 8 | PRIO_MIN + (PRIO_MAX - PRIO_MIN)/2 (0) | PRIO_MIN + (PRIO_MAX - PRIO_MIN)/2 (0) | xtd::diagnostics::process_priority_class::normal |
| 10 | PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 4 (10) | PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 4 (10) | xtd::diagnostics::process_priority_class::above_normal |
| 13 | PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 8 (15) | PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 8 (15) | xtd::diagnostics::process_priority_class::high |
| 24 | PRIO_MAX (20) | PRIO_MAX (20) | xtd::diagnostics::process_priority_class::real_time |
| ustring xtd::diagnostics::process::process_name | ( | ) | const |
Gets the name of the process.
| xtd::invalid_operation_exception | There is no process associated with this xtd::diagnostics::process object. |
| std::istream& xtd::diagnostics::process::standard_error | ( | ) |
Gets a stream used to read the error output of the application.
| xtd::invalid_operation_exception | There is no process associated with this xtd::diagnostics::process object. |
| std::ostream& xtd::diagnostics::process::standard_input | ( | ) |
Gets a stream used to write the input of the application.
| xtd::invalid_operation_exception | There is no process associated with this xtd::diagnostics::processes object. |
| std::istream& xtd::diagnostics::process::standard_output | ( | ) |
Gets a stream used to read the textual output of the application.
| xtd::invalid_operation_exception | There is no process associated with this xtd::diagnostics::process object. |
| bool xtd::diagnostics::process::start | ( | ) |
Starts (or reuses) the process resource that is specified by the xtd::diagnostics::process::start_info property of this Process component and associates it with the component.
| xtd::invalid_operation_exception | No file name was specified in the xtd::diagnostics::process component's xtd::diagnostics::process::start_info. |
|
static |
Starts the process resource that is specified by the parameter containing process start information (for example, the file name of the process to start) and associates the resource with a new xtd::diagnostics::process component.
| The | xtd::diagnostics::process_start_ifo that contains the information that is used to start the process, including the file name and any command-line arguments. |
| xtd::invalid_operation_exception | No file name was specified in the startInfo parameter's xtd::diagnostics::process_start_info::file_name property. |
Starts a process resource by specifying the name of a document or application file and associates the resource with a new Process component.
| file_name | The name of a document or application file to run in the process. |
| xtd::invalid_operation_exception | No file name was specified in the file_name parameter's xtd::diagnostics::process_start_info::file_name property. |
|
static |
Starts a process resource by specifying the name of an application and a set of command-line arguments, and associates the resource with a new xtd::diagnostics::process component.
| file_name | The name of a document or application file to run in the process. |
| arguments | Command-line arguments to pass when starting the process. |
| xtd::invalid_operation_exception | No file name was specified in the file_name parameter's xtd::diagnostics::process_start_info::file_name property. |
| const xtd::diagnostics::process_start_info& xtd::diagnostics::process::start_info | ( | ) | const |
Gets the properties to pass to the xtd::diagnostics::process::start() method of the xtd::diagnostics::process.
| xtd::diagnostics::process_start_info& xtd::diagnostics::process::start_info | ( | ) |
Gets the properties to pass to the xtd::diagnostics::process::start() method of the xtd::diagnostics::process.
| process& xtd::diagnostics::process::start_info | ( | const xtd::diagnostics::process_start_info & | value | ) |
Sets the properties to pass to the xtd::diagnostics::process::start() method of the xtd::diagnostics::process.
| value | The xtd::diagnostics::process_start_info that represents the data with which to start the process. These arguments include the name of the executable file or document used to start the process. |
| xtd::date_time xtd::diagnostics::process::start_time | ( | ) | const |
Gets the time that the associated process was started.
| xtd::invalid_operation_exception | There is no process associated with this xtd::diagnostics::process object. |
| process& xtd::diagnostics::process::wait_for_exit | ( | ) |
Instructs the xtd::diagnostics::process component to wait indefinitely for the associated process to exit.
| xtd::invalid_operation_exception | There is no process associated with this xtd::diagnostics::process object. |
Instructs the Process component to wait the specified number of milliseconds for the associated process to exit.
| milliseconds | The amount of time, in milliseconds, to wait for the associated process to exit. A value of 0 specifies an immediate return, and a value of -1 specifies an infinite wait.The amount of time, in milliseconds, to wait for the associated process to exit. A value of 0 specifies an immediate return, and a value of -1 specifies an infinite wait. |
| xtd::invalid_operation_exception | There is no process associated with this xtd::diagnostics::process object. |
| error_data_received_event xtd::diagnostics::process::error_data_received |
Occurs when an application writes to its redirected xtd::diagnostics::process::standard_error stream.
| exit_event xtd::diagnostics::process::exited |
Occurs when a process exits.
| output_data_received_event xtd::diagnostics::process::output_data_received |
Occurs each time an application writes a line to its redirected xtd::diagnostics::process::standard_output stream.