Questo articolo è stato tradotto automaticamente. Per visualizzare l'articolo in inglese, selezionare la casella di controllo Inglese. È possibile anche visualizzare il testo inglese in una finestra popup posizionando il puntatore del mouse sopra il testo.

Metodo Process.Start ()


Data di pubblicazione: ottobre 2016

Avvia (o riutilizza) la risorsa di processo specificata dalla proprietà StartInfo di questo componente Process e la associa al componente.

Spazio dei nomi:   System.Diagnostics
Assembly:  System (in System.dll)

public bool Start()

Valore restituito

Type: System.Boolean

true se viene avviata una risorsa di processo, false se non viene avviata alcuna risorsa di processo nuova (ad esempio, se è stato riutilizzato un processo esistente).

Exception Condition

Non è stato specificato alcun nome file nella proprietà StartInfo del componente Process.


Il membro ProcessStartInfo.UseShellExecute della proprietà StartInfo è true mentre ProcessStartInfo.RedirectStandardInput, ProcessStartInfo.RedirectStandardOutput o ProcessStartInfo.RedirectStandardError è true.


Si è verificato un errore durante l'apertura del file associato.


L'oggetto del processo è già stato eliminato.

Use this overload to start a process resource and associate it with the current T:System.Diagnostics.Process component. The return value true indicates that a new process resource was started. If the process resource specified by the P:System.Diagnostics.ProcessStartInfo.FileName member of the P:System.Diagnostics.Process.StartInfo property is already running on the computer, no additional process resource is started. Instead, the running process resource is reused and false is returned.

You can start a ClickOnce application by specifying 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 you are using Visual Studio, this overload of the M:System.Diagnostics.Process.Start method is the one that you insert into your code after you drag a T:System.Diagnostics.Process component onto the designer. Use the Properties window to expand the StartInfo category and write the appropriate value into the FileName property. Your changes will appear in the form's InitializeComponent procedure.

This overload of M:System.Diagnostics.Process.Start is not a static method. You must call it from an instance of the T:System.Diagnostics.Process class. Before calling M:System.Diagnostics.Process.Start, you must first specify P:System.Diagnostics.Process.StartInfo property information for this T:System.Diagnostics.Process instance, because that information is used to determine the process resource to start.

The other overloads of the M:System.Diagnostics.Process.Start method are static members. You do not need to create an instance of the T:System.Diagnostics.Process component before you call those overloads of the method. Instead, you can call M:System.Diagnostics.Process.Start for the T:System.Diagnostics.Process class itself, and a new T:System.Diagnostics.Process component is created if the process was started. Or, null is returned if a process was reused. The process resource is automatically associated with the new T:System.Diagnostics.Process component that is returned by the M:System.Diagnostics.Process.Start method.

The P:System.Diagnostics.Process.StartInfo members can be used to duplicate the functionality of the Run dialog box of the Windows Start menu. Anything that can be typed into a command line can be started by setting the appropriate values in the P:System.Diagnostics.Process.StartInfo property. The only P:System.Diagnostics.Process.StartInfo property that must be set is the P:System.Diagnostics.ProcessStartInfo.FileName property. The P:System.Diagnostics.ProcessStartInfo.FileName property does not have to be an executable file. It can be of any file type for which the extension has been associated with an application that is installed on the system. For example, the P:System.Diagnostics.ProcessStartInfo.FileName property can have a .txt extension if you have associated text files with an editor, such as Notepad, or it can have a .doc extension if you have associated.doc files with a word processing tool, such as Microsoft Word.

In the command line, you can specify actions to take for certain types of files. For example, you can print documents or edit text files. Specify these actions using the P:System.Diagnostics.ProcessStartInfo.Verb member of the P:System.Diagnostics.Process.StartInfo property. For other types of files, you can specify command-line arguments when you start the file from the Run dialog box. For example, you can pass a URL as an argument if you specify your browser as the P:System.Diagnostics.ProcessStartInfo.FileName. These arguments can be specified in the P:System.Diagnostics.Process.StartInfo property's P:System.Diagnostics.ProcessStartInfo.Arguments member.

If you have a path variable declared in your system using quotes, you must fully qualify that path when starting any process found in that location. Otherwise, the system will not find the path. For example, if c:\mypath is not in your path, and you add it using quotation marks: path = %path%;"c:\mypath", you must fully qualify any process in c:\mypath when starting it.


ASP.NET Web page and server control code executes in the context of the ASP.NET worker process on the Web server. If you use the Overload:System.Diagnostics.Process.Start method in an ASP.NET Web page or server control, the new process executes on the Web server with restricted permissions. The process does not start in the same context as the client browser, and does not have access to the user desktop.

Whenever you use M:System.Diagnostics.Process.Start to start a process, you might need to close it or you risk losing system resources. Close processes using M:System.Diagnostics.Process.CloseMainWindow or M:System.Diagnostics.Process.Kill. You can check whether a process has already been closed by using its P:System.Diagnostics.Process.HasExited property.

A note about apartment states in managed threads is necessary here. When P:System.Diagnostics.ProcessStartInfo.UseShellExecute is true on the process component's P:System.Diagnostics.Process.StartInfo property, make sure you have set a threading model on your application by setting the attribute [STAThread] on the main() method. Otherwise, a managed thread can be in an unknown state or put in the MTA state, the latter of which conflicts with P:System.Diagnostics.ProcessStartInfo.UseShellExecute being true. Some methods require that the apartment state not be unknown. If the state is not explicitly set, when the application encounters such a method, it defaults to MTA, and once set, the apartment state cannot be changed. However, MTA causes an exception to be thrown when the operating system shell is managing the thread.

The following example uses an instance of the T:System.Diagnostics.Process class to start a process.

using System;
using System.Diagnostics;
using System.ComponentModel;

namespace MyProcessSample
    class MyProcess
        public static void Main()
            Process myProcess = new Process();

                myProcess.StartInfo.UseShellExecute = false;
                // You can start any process, HelloWorld is a do-nothing example.
                myProcess.StartInfo.FileName = "C:\\HelloWorld.exe";
                myProcess.StartInfo.CreateNoWindow = true;
                // This code assumes the process you are starting will terminate itself. 
                // Given that is is started without a window so you cannot terminate it 
                // on the desktop, it must terminate itself or you can do it programmatically
                // from this application using the Kill method.
            catch (Exception e)


for full trust for the immediate caller. This member cannot be used by partially trusted code.

.NET Framework
Disponibile da 1.1
Torna all'inizio