Process.Run 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
重载
| 名称 | 说明 |
|---|---|
| Run(ProcessStartInfo, Nullable<TimeSpan>) |
启动描述 |
| Run(String, IEnumerable<String>, Boolean, Nullable<TimeSpan>) |
使用指定的文件名和可选参数启动进程,等待它退出,并返回其退出状态。 |
Run(ProcessStartInfo, Nullable<TimeSpan>)
- Source:
- Process.Scenarios.cs
启动描述 startInfo的过程,等待其退出,并返回其退出状态。
[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
参数
- startInfo
- ProcessStartInfo
ProcessStartInfo包含用于启动进程的信息。
返回
进程的退出状态。 如果进程因超时而终止, Canceled 则为 true。
- 属性
例外
timeout截断为整数毫秒,小于 -1 或大于 MaxValue。
startInfo 是 null。
将 UseShellExecute 设置为 true。
- 或者 -
RedirectStandardInput、 RedirectStandardOutput或 RedirectStandardError 设置为 true。 请改用相应的标准句柄属性来提供句柄。
适用于
Run(String, IEnumerable<String>, Boolean, Nullable<TimeSpan>)
- Source:
- Process.Scenarios.cs
使用指定的文件名和可选参数启动进程,等待它退出,并返回其退出状态。
[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
参数
- fileName
- String
要启动的可执行文件的名称。
- arguments
- IEnumerable<String>
要传递给进程的命令行参数。 传递 null 或空序列以启动进程,而无需其他参数。
- silent
- Boolean
当 true,将标准输入、输出和错误重定向到 null 设备时,确保进程不会生成可见的控制台输出。 当进程从父级继承标准句柄时 false。
返回
进程的退出状态。 如果进程因超时而终止, Canceled 则为 true。
- 属性
例外
timeout截断为整数毫秒,小于 -1 或大于 MaxValue。
fileName 是 null。
fileName 为空。