[How to ]Set Environment Variable by a Bat[Batch] file in Windows



Most of the Program required some environment variable to be defined like JAVA_HOME for Maven Project.
Many people even in today world do it by manually like go to advanced system setting in Windows and set the Environment Variables but for Techie people this is not the way to do.
Here I am sharing one Utility which will do thing for you guys.

Two ways to Define environment variable
  1. By Manually go to MY COMPUTER > System properties >Advanced System setting>Environment Variables
  2. Through Command Line (Bat file also ) :- For this you have to only only the Notepad and write the below line 
setx <ENVIRONMENT_VARIABLE_NAME>  "<REQUIRED PATH>"
Eg- setx JAVA_HOME "C:\Program Files (x86)\Java\jdk1.7.0_02"

and now save the file with .bat file (eg EvnironmentVariable.bat) Now you can just double click the bat file and it will automatically define the environment variable.

VERIFICATION OF INSTALL VARIABLE (FOR JAVA_HOME)
- for verify the installed variable you can check it in cmd
- for java_home - type "%JAVA_HOME%" in cmd , you will get like below snap.



Here I uploaded one bat file for Demo purpose .You can Download it


[How to ]Set Environment Variable by a Bat[Batch] file in Windows [How to ]Set Environment Variable by a Bat[Batch] file in Windows Reviewed by Admin on 09:56 Rating: 5

No comments:

Follow and +1 Us

Powered by Blogger.