ProcessStartInfo.Environment 屬性

定義

取得套用至這個處理序及其子處理序的環境變數。

public:
 property System::Collections::Generic::IDictionary<System::String ^, System::String ^> ^ Environment { System::Collections::Generic::IDictionary<System::String ^, System::String ^> ^ get(); };
public System.Collections.Generic.IDictionary<string,string?> Environment { get; }
public System.Collections.Generic.IDictionary<string,string> Environment { get; }
member this.Environment : System.Collections.Generic.IDictionary<string, string>
Public ReadOnly Property Environment As IDictionary(Of String, String)

屬性值

泛型字典,包含套用至這個處理序及其子處理序的環境變數。 預設為 null

備註

環境變數包含檔案的搜尋路徑、暫存盤的目錄、應用程式特定選項,以及其他類似的資訊。 雖然您無法直接設定 Environment 屬性,但您可以修改 屬性傳回的泛型字典。 例如,下列程式代碼會新增 TempPath 環境變數: myProcess.StartInfo.Environment.Add("TempPath", "C:\\Temp")。 您必須將 UseShellExecute 屬性設定為 false ,才能在變更 Environment 屬性之後啟動進程。 如果 為 UseShellExecutetrueInvalidOperationException 則會在呼叫 方法時 Start 擲回 。

在 .NET Framework 應用程式上,使用 Environment 屬性與使用 EnvironmentVariables 屬性相同。

適用於

另請參閱