Starts a process resource specified by the process start information passed in, for example the file name of the process to start. Associates the process resource with a new Process component.
[Visual Basic] Overloads Public Shared Function Start( _ ByVal startInfo As ProcessStartInfo _ ) As Process [C#] public static Process Start( ProcessStartInfo startInfo ); [C++] public: static Process* Start( ProcessStartInfo* startInfo ); [JScript] public static function Start( startInfo : ProcessStartInfo ) : Process;
A new Process component associated with the process resource, or a null reference (in Visual Basic Nothing) if no process resource is started (for example, if an existing process is reused).
Exception Type | Condition |
---|---|
ArgumentException | The startInfo parameter is a null reference (Nothing). |
Use this overload to start a process resource by specifying a ProcessStartInfo instance, and associate it with a new Process component. If the process is already running, no additional process resource is started. Instead, the existing process resource is reused and no new Process component is created. In such a case, instead of returning a new Process component, the call to Start returns a null reference (Nothing) to the calling procedure.
This overload lets you start a process without first instantiating a Process object. Using this overload with a ProcessStartInfo parameter is an alternate for the explicit steps of instantiating a Process, setting its StartInfo properties, and calling Start on the Process.
Using a ProcessStartInfo instance as the parameter lets you call Start with the most control over what is passed into the call to start process. If you only need to pass in a file name or a file name and arguments, it is not necessary to create a new ProcessStartInfo instance, although that is an option. The only StartInfo property that must be set is the FileName. The FileName does not need to be an executable. It can be any file type whose extension has been associated with an application installed on the system, for example ".txt" if you have associated text files with an editor like Notepad, or ".doc" if you have .doc files associated with a word processing tool like Microsoft Word.
This overload of the Start method is a static (in Visual Basic Shared) member. You do not need to create an instance of the Process component before you call the method. You can call Start on the Process class itself. The process resource is automatically associated with the new Process component returned by the call to the Start method.
Unlike the other overloads, the parameterless overload of Start is not a static (Shared) member. Use the paremeterless overload when you have already created a Process instance, specified start information including the file name, and want to start a process resource and associate it with the existing Process. Use one of the static (Shared) overloads when you want to create a new Process component rather than start a process on an existing component. Both this overload and the parameterless overload allow you to specify the start information for the process resource using a ProcessStartInfo instance.
Whenever you use Start to start a process, you must be sure to close it or you risk losing system resources. You close processes using CloseMainWindow or Kill. CloseMainWindow is used to close processes that contain a graphical interface, while Kill must be used for non-graphical applications that do not have a message pump to handle a windows Close request.
Note Currently, all processes started using a Process component open in a command window. They contain a message loop and you can attempt to close them using CloseMainWindow. This will change in a future release. Depending on how the non-graphical interface process is coded, CloseMainWindow could fail and Kill could be necessary in order to stop the process.
Process Class | Process Members | System.Diagnostics Namespace | Process.Start Overload List | StartInfo | FileName | ProcessStartInfo | CloseMainWindow | Kill