Save Time and Typing With Windows Shortcuts That Use Environment Variables


You may be wondering what an “environment variable” is. You’ve probably seen them—they are those expressions wrapped in percent signs that you sometimes see in file paths. They are shorthand expressions that stand for certain standard system properties. Some of these system properties are used frequently in filename paths and scripts. Having a short version can save considerable time and effort. This tip will show how convenient they can be and where to get a full explanation of how to use them.

No need to know system details

In addition to being short in length, environment variables have the important property of freeing you from having to actually know the details of a particular computer system. For example, the Windows  user account is often part of a file path. It would be pretty inconvenient to have to figure out the actual name of every user account on every system. So there is an environment variable that eliminates the need to actually know what any user account is called. When you write %USERNAME%, the computer knows you mean whoever is currently logged on. (I use upper case for environment variables but that is not necessary.)

Another example is the convenience of environment variables for accessing some frequently used folders. Every user account has its own collection of folders like (My) Documents, Favorites, Desktop, and so on. In Windows XP, these folders are located in C:\Documents and Settings\{user name}\. That’s a lot of typing plus we need to know the user name. An environment variable saves us from all that trouble. We can simply write the entire path as %USERPROFILE%\. Microsoft moved the user folders to a different location in Windows Vista/7 but %USERPROFILE% saves us from having to know where. This environment variable works in those systems also.

The two examples given are just a taste of the many uses of environment variables. Here is how to learn more.

More information about environment variables

There are a number of environment variables and a full discussion of how to use them is at the references given below. Tables showing the different environment variables and their meaning are given in these articles.

This tips section is maintained by Vic Laurie. Vic runs a Windows blog called The PC Informant and also operates a computer education website.

Click here for more items like this. Better still, get Tech Tips delivered via your RSS feeder or alternatively, have the RSS feed sent as email direct to your in-box.

Get your own favorite tip published!  Know a neat tech tip or trick?  Then why not have it published here and receive full credit?  Click here to tell us your tip.

Please rate this article: 

Your rating: None
Average: 4.1 (8 votes)