KNOW ABOUT LAUNCHING PROCESSES FROM .NET

There are some reasons ground you haw poverty to move a newborn impact from your .NET application, added than if your aggregation is a programme that is fashioned to move added programs. For example, you haw desire to exhibit a scheme tender in the user’s desirable scheme covering or unstoppered a book enter containing a index or promulgation aggregation for your newborn cipher version. If you hit a aggregation that requires administrative privileges, you haw end to separate it as a accepted individual until an administrative duty is required. At this point, you haw reopen the program, streaming as administrator, or move a impact that handles meet the elements that order elevated permissions.

Starting a New Process

The classes and methods that are utilised to move newborn processes are institute in the System.Diagnostics namespace. When using these items, it is thence multipurpose to allow the mass directive:

using System.Diagnostics;

All of the structure to move newborn programs that we module analyse in this article ingest the Start method of the Process class. The simplest edition is a noise method that accepts a azygos progress parameter. The constant contains the study and, optionally, the line of the aggregation or writing to open. When executed, the gist is kindred to typewriting the table of the constant into the talking incase that appears when you superior Run from the Windows Start menu. If a aggregation study is provided, the aggregation is launched. If the study of a writing is passed to the parameter, and the identify of the writing is qualified within Windows, the pertinent covering is launched and the writing is opened.

The mass cipher launches a newborn happening of the Notepad utility:

Process.Start(“notepad.exe”);

This warning functions aright because the notepad.exe enter crapper be institute within a folder that is automatically searched when play a process. If this were not the case, you would requirement to wage the flooded line to the executable, which would order cipher kindred to the following:

Process.Start(@”c:\windows\notepad.exe”);

As described earlier, the constant does not requirement to include the study of an workable file. It crapper include a document, scheme place address or added component that could be utilised from the Run talking box. For example, you crapper unstoppered a scheme place in the user’s desirable scheme covering using the mass code:

Process.Start(“http://www.blackwasp.co.uk/”);

Starting an Existing Process

The noise Start method returns an goal of the Process type. This goal contains aggregation most the aggregation that was started, including info most the streaming impact and whether it has been exited. We crapper obtain the Process goal by distribution the convey continuance to a variable:

Process p = Process.Start(“notepad.exe”);

Once the Process goal is available, it crapper be utilised to obtain info most the impact and crapper also be utilised to move added kindred impact using the happening method alteration of Start. For example, the mass cipher opens digit Notepad windows:

Process p = Process.Start("notepad.exe");
p.Start();

Comments are closed.