O'Reilly logo

C# 5.0 Unleashed by Bart De Smet

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required