简体   繁体   中英

Where Does Environment.GetEnvironmentVariables() Get Its Information?

I have a TT PowerShell script running as part of a C# project. That script references Environment.GetEnvironmentVariables() to get the contents of the PATH variable.

But the data returned includes paths that I need to change, and that do not match the path in Windows itself.

Where does this method get the paths from and how do I change them?

It uses the Windows API GetEnvironmentStrings() to get its data. (The Unicode version.)

Also see this documentation: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682653%28v=vs.85%29.aspx

To set an environment variable, you can use this overload of Environment.SetEnvironmentVariable() which lets you specify the Process, User or Machine set.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM