使用 System.Environment 类的 GetEnvironmentVariable GetEnvironmentVariables SetEnvironmentVariable 方法。 参考:How do I get and set Environment variables?