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")。 必须将 属性设置为 UseShellExecutefalse ,才能在更改 Environment 属性后启动进程。 如果 UseShellExecutetrueInvalidOperationException 则在调用 方法时 Start 引发 。

在.NET Framework应用程序中,使用 Environment 属性与使用 EnvironmentVariables 属性相同。

适用于

另请参阅