ProcessStartInfo::Environment Property

.NET Framework (current version)
 

Gets the environment variables that apply to this process and its child processes.

Namespace:   System.Diagnostics
Assembly:  System (in System.dll)

public:
property IDictionary<String^, String^>^ Environment {
	IDictionary<String^, String^>^ get();
}

Property Value

Type: System.Collections.Generic::IDictionary<String^, String^>^

A generic dictionary containing the environment variables that apply to this process and its child processes. The default is null.

The environment variables contain search paths for files, directories for temporary files, application-specific options, and other similar information. Although you cannot directly set the Environment property, you can modify the generic dictionary returned by the property. For example, the following code adds a TempPath environment variable: myProcess.StartInfo.Environment.Add("TempPath", "C:\\Temp"). You must set the UseShellExecute property to false to start the process after changing the Environment property. If UseShellExecute is true, an InvalidOperationException is thrown when the Start method is called.

On .NET Framework applications, using the Environment property is the same as using the EnvironmentVariables property.

.NET Framework
Available since 4.6
Return to top
Show: