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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.