[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 

Eg- setx JAVA_HOME “C:Program Files (x86)Javajdk1.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.

– 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

Add a Comment

Your email address will not be published. Required fields are marked *