Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can a script.bat make changes to Windows PATH Environment Variable

I'm trying to write a script that when clicked will add a couple of entries to the PATH Environment variable in Windows, instead of making the changes manually. I see .bat files being used all the time on Windows for a variety of reasons, so can a .bat script help me with something like that?

I actually need to download a zip from a location on the Internet, extract it to a specified location, then update the PATH in environment variable. Never done this before so any hints appreciated.

like image 831
Berming Avatar asked Sep 30 '10 23:09

Berming


People also ask

How does Windows PATH variable work?

The PATH variable prevents us from having to write out the entire path to a program on the CLI every time we run it. Essentially, it's just a variable that stores a bunch of shortcuts. When you enter a command on the CLI without using the absolute path, the operating system checks the PATH variable.


1 Answers

If you wish to change/update the PATH permanently in the environment variable, you can use the SETX command e.g.

setx path "%PATH%;C:\New Folder" 

For more details information on %PATH% and other variables to access to system folder, refer to http://vlaurie.com/computers2/Articles/environment.htm

like image 131
drhanlau Avatar answered Sep 19 '22 22:09

drhanlau