Process.StartAndForget 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
| 名稱 | Description |
|---|---|
| StartAndForget(ProcessStartInfo) |
啟動由 描述的 |
| StartAndForget(String, IEnumerable<String>) |
以指定的檔案名稱和可選參數啟動程序,釋放所有相關資源,並回傳程序 ID。 |
StartAndForget(ProcessStartInfo)
啟動由 描述的 startInfo程序,釋放所有相關資源,並回傳程序 ID。
public:
static int StartAndForget(System::Diagnostics::ProcessStartInfo ^ startInfo);
[System.Runtime.Versioning.SupportedOSPlatform("maccatalyst")]
[System.Runtime.Versioning.UnsupportedOSPlatform("ios")]
[System.Runtime.Versioning.UnsupportedOSPlatform("tvos")]
public static int StartAndForget(System.Diagnostics.ProcessStartInfo startInfo);
[<System.Runtime.Versioning.SupportedOSPlatform("maccatalyst")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("ios")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("tvos")>]
static member StartAndForget : System.Diagnostics.ProcessStartInfo -> int
Public Shared Function StartAndForget (startInfo As ProcessStartInfo) As Integer
參數
- startInfo
- ProcessStartInfo
那個 ProcessStartInfo 包含啟動流程所使用的資訊。
傳回
啟動程序的程序 ID。
- 屬性
例外狀況
startInfo 是 null。
其中一個或多個 RedirectStandardInput、 RedirectStandardOutput、 RedirectStandardError 或 設為 true。 在「發射後忘記」情境中不支援串流重定向,因為必須先排空重定向的串流以避免死結。
-或者-
UseShellExecute 設定為 true。 在「發射後忘記」的情境中不支援 shell 執行,因為在 Windows 上,它可能無法建立新程序,導致無法回傳有效的程序 ID。
備註
當未提供標準句柄(StandardInputHandle、 StandardOutputHandle、 或 StandardErrorHandle)時,預設會將其導向到空檔。
此方法設計用於呼叫者想啟動程序且不需進一步互動的「發射後遺忘」情境。 它啟動程序,釋放所有相關資源,並回傳程序 ID。 啟動程序會獨立執行。
適用於
StartAndForget(String, IEnumerable<String>)
以指定的檔案名稱和可選參數啟動程序,釋放所有相關資源,並回傳程序 ID。
[System.Runtime.Versioning.SupportedOSPlatform("maccatalyst")]
[System.Runtime.Versioning.UnsupportedOSPlatform("ios")]
[System.Runtime.Versioning.UnsupportedOSPlatform("tvos")]
public static int StartAndForget(string fileName, System.Collections.Generic.IEnumerable<string>? arguments = default);
[<System.Runtime.Versioning.SupportedOSPlatform("maccatalyst")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("ios")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("tvos")>]
static member StartAndForget : string * seq<string> -> int
Public Shared Function StartAndForget (fileName As String, Optional arguments As IEnumerable(Of String) = Nothing) As Integer
參數
- fileName
- String
執行檔名稱作為起始。
- arguments
- IEnumerable<String>
命令列參數,傳遞給程序。 通過 null 或空序列即可啟動程序,無需額外參數。
傳回
啟動程序的程序 ID。
- 屬性
例外狀況
fileName 是 null。
fileName 空無一人。
備註
此方法設計用於呼叫者想啟動程序且不需進一步互動的「發射後遺忘」情境。 它啟動程序,擷取程序 ID,釋放所有相關資源,並回傳程序 ID。 啟動程序會獨立執行。
標準帳號預設會被導向到 null 檔案。