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... | |
Public Events | |
| error_data_received_event | error_data_received |
| Occurs when an application writes to its redirected xtd::diagnostics::process::standard_error stream. | |
| exit_event | exited |
| Occurs when a process exits. | |
| output_data_received_event | output_data_received |
| Occurs each time an application writes a line to its redirected xtd::diagnostics::process::standard_output stream. | |
Public Constructors | |
| process () | |
| Initializes a new instance of the xtd::diagnostics::process class. | |
Public Properties | |
| auto | base_priority () const -> xtd::int32 |
| Gets the base priority xof the associated process. | |
| auto | enable_raising_events () const -> bool |
| Gets whether the xtd::diagnostics::process::exited event should be raised when the process terminates. | |
| auto | enable_raising_events (bool value) -> xtd::diagnostics::process & |
| Sets whether the xtd::diagnostics::process::exited event should be raised when the process terminates. | |
| auto | exit_code () const -> xtd::int32 |
| Gets the value that the associated process specified when it terminated. | |
| auto | exit_time () const -> xtd::date_time |
| Gets the time that the associated process exited. | |
| auto | handle () const -> xtd::intptr |
| Gets the native handle of the associated process. | |
| auto | has_exited () const -> bool |
| Gets a value indicating whether the associated process has been terminated. | |
| auto | id () const -> xtd::int32 |
| Gets the unique identifier for the associated process. | |
| auto | machine_name () const -> xtd::string |
| Gets the name of the computer the associated process is running on. | |
| auto | priority_class () const -> xtd::diagnostics::process_priority_class |
| Gets the overall priority category for the associated process. | |
| auto | priority_class (xtd::diagnostics::process_priority_class value) -> xtd::diagnostics::process & |
| Sets the overall priority category for the associated process. | |
| auto | process_name () const -> xtd::string |
| Gets the name of the process. | |
| auto | standard_error () -> std::istream & |
| Gets a stream used to read the error output of the application. | |
| auto | standard_input () -> std::ostream & |
| Gets a stream used to write the input of the application. | |
| auto | standard_output () -> std::istream & |
| Gets a stream used to read the textual output of the application. | |
| auto | start_info () const -> const xtd::diagnostics::process_start_info & |
| Gets the properties to pass to the xtd::diagnostics::process::start() method of the xtd::diagnostics::process. | |
| auto | start_info () -> xtd::diagnostics::process_start_info & |
| Gets the properties to pass to the xtd::diagnostics::process::start() method of the xtd::diagnostics::process. | |
| auto | start_info (const xtd::diagnostics::process_start_info &value) -> xtd::diagnostics::process & |
| Sets the properties to pass to the xtd::diagnostics::process::start() method of the xtd::diagnostics::process. | |
| auto | start_time () const -> xtd::date_time |
| Gets the time that the associated process was started. | |
Public Methods | |
| auto | close () -> void |
| Frees all the resources that are associated with this component. | |
| auto | kill () -> void |
| Immediately stops the associated process. | |
| auto | start () -> bool |
| 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. | |
| auto | wait_for_exit () -> xtd::diagnostics::process & |
| Instructs the xtd::diagnostics::process component to wait indefinitely for the associated process to exit. | |
| auto | wait_for_exit (int32 milliseconds) -> xtd::diagnostics::process & |
| Instructs the Process component to wait the specified number of milliseconds for the associated process to exit. | |
Public Static Methods | |
| static auto | start (const xtd::diagnostics::process_start_info &start_info) -> xtd::diagnostics::process |
| 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. | |
| static auto | start (const xtd::string &file_name) -> xtd::diagnostics::process |
| Starts a process resource by specifying the name of a document or application file and associates the resource with a new Process component. | |
| static auto | start (const xtd::string &file_name, const xtd::string &arguments) -> xtd::diagnostics::process |
| 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. | |
Protected Methods | |
| virtual auto | on_exited () -> void |
| Raises the xtd::diagnostics::process::exited event. | |
Additional Inherited Members | |
| object ()=default | |
| Create a new instance of the ultimate base class object. | |
| virtual bool | equals (const object &obj) const noexcept |
| Determines whether the specified object is equal to the current object. | |
| virtual xtd::size | get_hash_code () const noexcept |
| Serves as a hash function for a particular type. | |
| virtual type_object | get_type () const noexcept |
| Gets the type of the current instance. | |
| template<class object_t> | |
| xtd::unique_ptr_object< object_t > | memberwise_clone () const |
| Creates a shallow copy of the current object. | |
| virtual xtd::string | to_string () const |
| Returns a xtd::string that represents the current object. | |
| virtual int32 | compare_to (const process &obj) const noexcept=0 |
| Compares the current instance with another object of the same type. | |
| template<class object_a_t, class object_b_t> | |
| static bool | equals (const object_a_t &object_a, const object_b_t &object_b) noexcept |
| Determines whether the specified object instances are considered equal. | |
| template<class object_a_t, class object_b_t> | |
| static bool | reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept |
| Determines whether the specified object instances are the same instance. | |
| xtd::diagnostics::process::process | ( | ) |
Initializes a new instance of the xtd::diagnostics::process class.
|
nodiscard |
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 |
|
nodiscard |
Gets whether the xtd::diagnostics::process::exited event should be raised when the process terminates.
| auto xtd::diagnostics::process::enable_raising_events | ( | bool | value | ) | -> xtd::diagnostics::process & |
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. |
|
nodiscard |
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. |
|
nodiscard |
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. |
|
nodiscard |
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. |
|
nodiscard |
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. |
|
nodiscard |
Gets the unique identifier for the associated process.
| xtd::invalid_operation_exception | The process's Id property has not been set. |
|
nodiscard |
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. |
|
nodiscard |
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 |
| auto xtd::diagnostics::process::priority_class | ( | xtd::diagnostics::process_priority_class | value | ) | -> xtd::diagnostics::process & |
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 |
|
nodiscard |
Gets the name of the process.
| xtd::invalid_operation_exception | There is no process associated with this xtd::diagnostics::process object. |
|
nodiscard |
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. |
|
nodiscard |
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. |
|
nodiscard |
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. |
|
nodiscard |
Gets the properties to pass to the xtd::diagnostics::process::start() method of the xtd::diagnostics::process.
|
nodiscard |
Gets the properties to pass to the xtd::diagnostics::process::start() method of the xtd::diagnostics::process.
| auto xtd::diagnostics::process::start_info | ( | const xtd::diagnostics::process_start_info & | value | ) | -> xtd::diagnostics::process & |
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. |
|
nodiscard |
Gets the time that the associated process was started.
| xtd::invalid_operation_exception | There is no process associated with this xtd::diagnostics::process object. |
| auto xtd::diagnostics::process::close | ( | ) | -> void |
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. |
| auto xtd::diagnostics::process::kill | ( | ) | -> void |
Immediately stops the associated process.
| xtd::invalid_operation_exception | There is no process associated with this xtd::diagnostics::process object. |
| auto xtd::diagnostics::process::start | ( | ) | -> bool |
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. |
| auto xtd::diagnostics::process::wait_for_exit | ( | ) | -> xtd::diagnostics::process & |
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. |
| auto xtd::diagnostics::process::wait_for_exit | ( | int32 | milliseconds | ) | -> xtd::diagnostics::process & |
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. |
|
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. |
|
static |
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. |
|
protectedvirtual |
Raises the xtd::diagnostics::process::exited event.
| 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.