xtd 0.2.0
Loading...
Searching...
No Matches

◆ start() [1/4]

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.

Returns
true if a process resource is started; false if no new process resource is started (for example, if an existing process is reused).
Exceptions
xtd::invalid_operation_exceptionNo file name was specified in the xtd::diagnostics::process component's xtd::diagnostics::process::start_info.
Examples
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.
#include <xtd/diagnostics/process>
#include <xtd/block_scope>
#include <xtd/console>
using namespace xtd;
using namespace xtd::diagnostics;
auto main() -> int {
try {
block_scope_(auto my_process = process {}) {
my_process.start_info().use_shell_execute(false);
// You can start any process other guidgen.
my_process.start_info().file_name("guidgen");
my_process.start_info().create_no_window(true);
my_process.start();
// This code assumes the process you are starting will terminate itself.
// Given that it is started without a window so you cannot terminate it
// on the desktop, it must terminate itself or you can do it programmatically
// from this application using the kill method.
}
} catch (const std::exception& e) {
}
}
// This code can produce the following output :
//
// 1549cf47-b1c9-4333-96e5-4eabffbd9fbd
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
Provides access to local and remote processes and enables you to start and stop local system processe...
Definition process.h:49
#define block_scope_(...)
The specified expression is cleared automatically when the scope is ended.
Definition block_scope.h:25
@ e
The E key.
The xtd::diagnostics namespace provides classes that allow you to interact with system processes,...
Definition assert_dialog_result.h:10
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10