Este artículo se tradujo automáticamente. Para ver el artículo en inglés, active la casilla Inglés. Además, puede mostrar el texto en inglés en una ventana emergente si mueve el puntero del mouse sobre el texto.
Traducción
Inglés

ProcessStartInfo.UseShellExecute (Propiedad)

 

Gets or sets a value indicating whether to use the operating system shell to start the process.

Espacio de nombres:   System.Diagnostics
Ensamblado:  System (en System.dll)

public bool UseShellExecute { get; set; }

Valor de propiedad

Type: System.Boolean

true if the shell should be used when starting the process; false if the process should be created directly from the executable file. The default is true.

Setting this property to false enables you to redirect input, output, and error streams.

System_CAPS_noteNota

   P:System.Diagnostics.ProcessStartInfo.UseShellExecute must be false if the P:System.Diagnostics.ProcessStartInfo.UserName property is not null or an empty string, or an T:System.InvalidOperationException will be thrown when the M:System.Diagnostics.Process.Start(System.Diagnostics.ProcessStartInfo) method is called.

When you use the operating system shell to start processes, you can start any document (which is any registered file type associated with an executable that has a default open action) and perform operations on the file, such as printing, by using the T:System.Diagnostics.Process object. When P:System.Diagnostics.ProcessStartInfo.UseShellExecute is false, you can start only executables by using the T:System.Diagnostics.Process object.

System_CAPS_noteNota

UseShellExecute must be true if you set the ErrorDialog property to true.

The P:System.Diagnostics.ProcessStartInfo.WorkingDirectory property behaves differently depending on the value of the P:System.Diagnostics.ProcessStartInfo.UseShellExecute property. When P:System.Diagnostics.ProcessStartInfo.UseShellExecute is true, the P:System.Diagnostics.ProcessStartInfo.WorkingDirectory property specifies the location of the executable. If P:System.Diagnostics.ProcessStartInfo.WorkingDirectory is an empty string, it is assumed that the current directory contains the executable.

When P:System.Diagnostics.ProcessStartInfo.UseShellExecute is false, the P:System.Diagnostics.ProcessStartInfo.WorkingDirectory property is not used to find the executable. Instead, it is used only by the process that is started and has meaning only within the context of the new process. When P:System.Diagnostics.ProcessStartInfo.UseShellExecute is false, the P:System.Diagnostics.ProcessStartInfo.FileName property can be either a fully qualified path to the executable, or a simple executable name that the system will attempt to find within folders specified by the PATH environment variable.

// Run "csc.exe /r:System.dll /out:sample.exe stdstr.cs". UseShellExecute is false because we're specifying
// an executable directly and in this case depending on it being in a PATH folder. By setting
// RedirectStandardOutput to true, the output of csc.exe is directed to the Process.StandardOutput stream
// which is then displayed in this console window directly.    
Process compiler = new Process();
compiler.StartInfo.FileName = "csc.exe";
compiler.StartInfo.Arguments = "/r:System.dll /out:sample.exe stdstr.cs";
compiler.StartInfo.UseShellExecute = false;
compiler.StartInfo.RedirectStandardOutput = true;
compiler.Start();    

Console.WriteLine(compiler.StandardOutput.ReadToEnd());

compiler.WaitForExit();

.NET Framework
Disponible desde 1.1
Volver al principio
Mostrar: