C # setting and getting system environment variables

Source: Internet
Author: User
C # setting and getting environment variables

1. Preface

本来想拿学校机房的Android编辑器直接粘到自己电脑上用,发现它的eclipse是32位的,而我的JDK是64位的,于是想到干脆装两个JDK,用C#做一个能够更改环境变量的程序

2. Code

Static methods under the Environment class

Get Environment variables:

public static string GetEnvironmentVariable(string variable, EnvironmentVariableTarget target);参数://   variable://     环境变量名。////   target://     System.EnvironmentVariableTarget 值之一,环境变量的位置。    

Set Environment variables:

public static void SetEnvironmentVariable(string variable, string value, EnvironmentVariableTarget target);参数://   variable://     环境变量名。////   value://     要分配给 variable 的值。////   target://     System.EnvironmentVariableTarget 值之一,环境变量的位置。

PS: This method of setting the environment variable can take effect without restarting the computer! (If the third argument is not added, only the environment variables of the current process will be modified)

C # setting and getting system environment variables

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.