Starting Processes

Spawning another process is simple using the Process.Start method. The easiest way to achieve the task at hand is to specify an executable filename. Overloads exist that take in more information, such as arguments and user credentials, to perform a “run as” execution. Let’s keep things simple and start cmd.exe as shown here. Notice that we don’t specify a full path and rely on the environment settings to resolve the path automatically:

var cmd = Process.Start("cmd.exe");

Note: Shell Execute Behavior

The managed Process API is a wrapper around the CreateProcess Win32 API as well as the ShellExecute API provided by the Windows Shell. Depending on the use of the API, either of the two is chosen. For example, when passing an HTTP ...

Get C# 5.0 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.