Creating System Environment Variables in Windows 7

Date: January 30th, 2011
Author: Good Peace

Every administrator who uses batch scripts is well aware of the built-in environment variables (WinDir, Path, ProgramFiles, etc.). Using them makes your batch scripts a lot more portable on other systems and is overall a rather good practice. For example instead of modifying a batch script for a different system in which the Windows directory is located in a different place you can simply use the WinDir environment variable. We use it like so:

Creating System Environment Variables in Windows 7

Simply put it between two % to specify that this is an environment variable.

Creating System Environment Variables in Windows 7

If you often use a particular path or any other kind of value why not create an environment variable just for it?

To do that, simply open Control Panel:

Creating System Environment Variables in Windows 7

In the right pane, navigate to System and Maintenance:

Creating System Environment Variables in Windows 7

Navigate to System:

Creating System Environment Variables in Windows 7

In the left pane click on Advanced system settings. A new window will appear:

Creating System Environment Variables in Windows 7

In the Advanced tab click on the Environment Variables button and a new window will open:

Creating System Environment Variables in Windows 7

In the System variables group click the New button (the lower of the two New buttons) and a new dialog will appear:

Creating System Environment Variables in Windows 7

Enter the name of the variable and its value:

Creating System Environment Variables in Windows 7

Click OK and there you have it:

Creating System Environment Variables in Windows 7

Click OK to close the Environment variables window and OK to close the System Properties window. To check if the variable is set simply restart the Command Prompt and use the echo command (do not forget the two %):

Creating System Environment Variables in Windows 7

VN:F [1.9.18_1163]
Rating: 0.0/10 (10 votes cast)
Creating System Environment Variables in Windows 7, 0.0 out of 10 based on 10 ratings

Leave a Reply