Process.Run Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
| Name | Description |
|---|---|
| Run(ProcessStartInfo, Nullable<TimeSpan>) |
Starts the process described by |
| Run(String, IEnumerable<String>, Boolean, Nullable<TimeSpan>) |
Starts a process with the specified file name and optional arguments, waits for it to exit, and returns its exit status. |
Run(ProcessStartInfo, Nullable<TimeSpan>)
- Source:
- Process.Scenarios.cs
Starts the process described by startInfo, waits for it to exit, and returns its exit status.
[System.Runtime.Versioning.SupportedOSPlatform("maccatalyst")]
[System.Runtime.Versioning.UnsupportedOSPlatform("ios")]
[System.Runtime.Versioning.UnsupportedOSPlatform("tvos")]
public static System.Diagnostics.ProcessExitStatus Run(System.Diagnostics.ProcessStartInfo startInfo, TimeSpan? timeout = default);
[<System.Runtime.Versioning.SupportedOSPlatform("maccatalyst")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("ios")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("tvos")>]
static member Run : System.Diagnostics.ProcessStartInfo * Nullable<TimeSpan> -> System.Diagnostics.ProcessExitStatus
Public Shared Function Run (startInfo As ProcessStartInfo, Optional timeout As Nullable(Of TimeSpan) = Nothing) As ProcessExitStatus
Parameters
- startInfo
- ProcessStartInfo
The ProcessStartInfo that contains the information used to start the process.
The maximum amount of time to wait for the process to exit. When null, waits indefinitely. If the process does not exit within the specified timeout, it is killed.
Returns
The exit status of the process. If the process is killed due to timeout, Canceled is true.
- Attributes
Exceptions
timeout, truncated to a whole number of milliseconds, is less than -1 or greater than MaxValue.
startInfo is null.
UseShellExecute is set to true.
-or-
RedirectStandardInput, RedirectStandardOutput, or RedirectStandardError is set to true. Use the corresponding standard handle properties to supply handles instead.
Applies to
Run(String, IEnumerable<String>, Boolean, Nullable<TimeSpan>)
- Source:
- Process.Scenarios.cs
Starts a process with the specified file name and optional arguments, waits for it to exit, and returns its exit status.
[System.Runtime.Versioning.SupportedOSPlatform("maccatalyst")]
[System.Runtime.Versioning.UnsupportedOSPlatform("ios")]
[System.Runtime.Versioning.UnsupportedOSPlatform("tvos")]
public static System.Diagnostics.ProcessExitStatus Run(string fileName, System.Collections.Generic.IEnumerable<string>? arguments = default, bool silent = false, TimeSpan? timeout = default);
[<System.Runtime.Versioning.SupportedOSPlatform("maccatalyst")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("ios")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("tvos")>]
static member Run : string * seq<string> * bool * Nullable<TimeSpan> -> System.Diagnostics.ProcessExitStatus
Public Shared Function Run (fileName As String, Optional arguments As IEnumerable(Of String) = Nothing, Optional silent As Boolean = false, Optional timeout As Nullable(Of TimeSpan) = Nothing) As ProcessExitStatus
Parameters
- fileName
- String
The name of the executable to start.
- arguments
- IEnumerable<String>
The command-line arguments to pass to the process. Pass null or an empty sequence to start the process without additional arguments.
- silent
- Boolean
When true, redirects standard input, output, and error to the null device, ensuring the process produces no visible console output. When false, the process inherits standard handles from the parent.
The maximum amount of time to wait for the process to exit. When null, waits indefinitely. If the process does not exit within the specified timeout, it is killed.
Returns
The exit status of the process. If the process is killed due to timeout, Canceled is true.
- Attributes
Exceptions
timeout, truncated to a whole number of milliseconds, is less than -1 or greater than MaxValue.
fileName is null.
fileName is empty.