System.Diagnostics.Process.StartInfo Property

Gets or sets the properties to pass to the Process.Start method of the System.Diagnostics.Process.

Syntax

[System.ComponentModel.Browsable(false)]
[System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Content)]
[System.Diagnostics.MonitoringDescription("Information for the start of this process.")]
public ProcessStartInfo StartInfo { get; set; }

Value

Documentation for this section has not yet been entered.

Remarks

Process.StartInfo represents the set of parameters to use to start a process. When Process.Start is called, the Process.StartInfo is used to specify the process to start. The only necessary Process.StartInfo member to set is the ProcessStartInfo.FileName property. Starting a process by specifying the ProcessStartInfo.FileName property is similar to typing the information in the Run dialog box of the Windows Start menu. Therefore, the ProcessStartInfo.FileName property does not need to represent an executable file. It can be of any file type for which the extension has been associated with an application installed on the system. For example the ProcessStartInfo.FileName can have a .txt extension if you have associated text files with an editor, such as Notepad, or it can have a .doc if you have associated.doc files with a word processing tool, such as Microsoft Word. Similarly, in the same way that the Run dialog box can accept an executable file name with or without the .exe extension, the .exe extension is optional in the ProcessStartInfo.FileName member. For example, you can set the ProcessStartInfo.FileName property to either "Notepad.exe" or "Notepad".

You can start a ClickOnce application by setting the ProcessStartInfo.FileName property to the location (for example, a Web address) from which you originally installed the application. Do not start a ClickOnce application by specifying its installed location on your hard drive.

If the file name involves a nonexecutable file, such as a .doc file, you can include a verb specifying what action to take on the file. For example, you could set the ProcessStartInfo.Verb to "Print" for a file ending in the .doc extension. The file name specified in the ProcessStartInfo.FileName property does not need to have an extension if you manually enter a value for the ProcessStartInfo.Verb property. However, if you use the ProcessStartInfo.Verbs property to determine what verbs are available, you must include the extension.

You can change the parameters specified in the Process.StartInfo property up to the time that you call the erload:System.Diagnostics.Process.Start method on the process. After you start the process, changing the Process.StartInfo values does not affect or restart the associated process. If you call the Process.Start(ProcessStartInfo) method with the ProcessStartInfo.UserName and ProcessStartInfo.Password properties set, the unmanaged CreateProcessWithLogonW function is called, which starts the process in a new window even if the ProcessStartInfo.CreateNoWindow property value is true or the ProcessStartInfo.WindowStyle property value is ProcessWindowStyle.Hidden.

If you did not use the erload:System.Diagnostics.Process.Start method to start a process, the Process.StartInfo property does not reflect the parameters used to start the process. For example, if you use erload:System.Diagnostics.Process.GetProcesses to get an array of processes running on the computer, the Process.StartInfo property of each System.Diagnostics.Process does not contain the original file name or arguments used to start the process.

When the process is started, the file name is the file that populates the (read-only) Process.MainModule property. If you want to retrieve the executable file that is associated with the process after the process has started, use the Process.MainModule property. If you want to set the executable file of a System.Diagnostics.Process instance for which an associated process has not been started, use the Process.StartInfo property's ProcessStartInfo.FileName member. Because the members of the Process.StartInfo property are arguments that are passed to the Process.Start method of a process, changing the ProcessStartInfo.FileName property after the associated process has started will not reset the Process.MainModule property. These properties are used only to initialize the associated process.

Requirements

Namespace: System.Diagnostics
Assembly: System (in System.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0