Speed Linking, May 9, 2007 Create Your Own Windows Environmental Variables Or Edit Existing Ones

Saman’s Big Ole List Of Windows Environmental Variables

Written by Saman Sadeghi on May 9, 2007 Add comments

I had a lot of fun writing my Saman’s Big Ole List Of Windows XP Run Commands article, and judging from the comments, you guys like reading them so I thought I’d create a list of Windows Environmental Variables!! These variables are present in Windows 2000, XP and Vista.

About

Environment variables are used in every Operating System, they are variables that you can call through the command prompt, a batch file or even through the Address Bar. Here is one of Microsoft’s definitions:

Environment variables are strings that contain information such as drive, path, or file name. They control the behavior of various programs. For example, the TEMP environment variable specifies the location in which programs place temporary files.

There are two categories of Environmental Variables, Local and System:

  • Local variables are set when the user logs in and will only pertain to that user, ie %APPDATA%
  • System variables pertain to Windows itself, ie %SYSTEMROOT%

Note

I wrote the list in uppercase, but these variables are not case sensitive when you actually call them! Remember that you will need to include the percent signs when calling these variables, ie:

C:\Documents and Settings\%username%\Application Data

Also, you can invoke most of these variables through the handy Windows Run prompt. Just hit the Windows Key+R, then enter the command and the system will open that folder!

The List

I wrote the list in alphabetical order for your viewing pleasure!

%ALLUSERSPROFILE% - Local

Returns the location of the All Users Profile.

%APPDATA% - Local

Returns the location where applications store data by default.

%CD% - Local

Returns the current directory string.

%CMDCMDLINE% - Local

Returns the exact command line used to start the current Cmd.exe.

%CMDEXTVERSION% - System

Returns the version number of the current Command Processor Extensions.

%COMPUTERNAME% - System

Returns the name of the computer.

%COMSPEC% - System

Returns the exact path to the command shell executable.

%DATE% - System

Returns the current date. Uses the same format as the date /t command. Generated by Cmd.exe.

%ERRORLEVEL% - System

Returns the error code of the most recently used command. A non zero value usually indicates an error.

%HOMEDRIVE% - System

Returns which local workstation drive letter is connected to the user’s home directory. Set based on the value of the home directory. The user’s home directory is specified in Local Users and Groups.

%HOMEPATH% - System

Returns the full path of the user’s home directory. Set based on the value of the home directory. The user’s home directory is specified in Local Users and Groups.

%HOMESHARE% - System

Returns the network path to the user’s shared home directory. Set based on the value of the home directory. The user’s home directory is specified in Local Users and Groups.

%LOGONSERVER% - Local

Returns the name of the domain controller that validated the current logon session.

%NUMBER_OF_PROCESSORS% - System

Specifies the number of processors installed on the computer.

%OS% - System

Returns the operating system name. Windows 2000 displays the operating system as Windows_NT.

%PATH% - System

Specifies the search path for executable files.

%PATHEXT% - System

Returns a list of the file extensions that the operating system considers to be executable.

%PROCESSOR_ARCHITECTURE% - System

Returns the chip architecture of the processor. Values: x86, IA64.

%PROCESSOR_IDENTIFIER% - System

Returns a description of the processor.

%PROCESSOR_LEVEL% - System

Returns the model number of the processor installed on the computer.

%PROCESSOR_REVISION% - System

Returns the revision number of the processor.

%PROMPT% - Local

Returns the command prompt settings for the current interpreter. Generated by Cmd.exe.

%RANDOM% - System

Returns a random decimal number between 0 and 32767. Generated by Cmd.exe.

%SYSTEMDRIVE% - System

Returns the drive containing the Windows XP root directory (that is, the system root).

%SYSTEMROOT% - System

Returns the location of the Windows XP root directory.

%TEMP% and %TMP% - System and User

Returns the default temporary directories that are used by applications available to users who are currently logged on. Some applications require TEMP and others require TMP.

%TIME% - System

Returns the current time. Uses the same format as the time /t command. Generated by Cmd.exe.

%USERDOMAIN% - Local

Returns the name of the domain that contains the user’s account.

%USERNAME% - Local

Returns the name of the user who is currently logged on.

%USERPROFILE% - Local

Returns the location of the profile for the current user.

%WINDIR% - System

Returns the location of the operating system directory.

This post is filed in: Command Prompt and has been viewed 1,836 views times.

Speed Linking, May 9, 2007 Create Your Own Windows Environmental Variables Or Edit Existing Ones

Frog Mario Hops For These Related Posts:


Frog Mario
  • Create Your Own Windows Environmental Variables Or Edit Existing Ones
  • Windows XP’s Hidden Programs
  • Set Your IP Address Via Batch File
  • Windows Tip: Batch Files
  • Shutdown Multiple Windows Machines From The Command Prompt


  • RSS feed | Trackback URI

    9 Comments »

    Comment by derrich 2007-05-09 10:45:39

    MyAvatars 0.2

    Great! Thanks, Saman. Now I have a nosebleed. :shock: :razz:

    Comment by Saman Sadeghi 2007-05-11 09:47:30

    MyAvatars 0.2

    :lol: You should have seen me when i wrote the list!

    Comment by derrich 2007-05-13 11:25:29

     
     
     
    Comment by dotnetnuke 2007-05-10 06:31:05

    MyAvatars 0.2

    Hi Saman, this is a great article and i translated it to Turkish (included a backlink to here)
    You can check Turkish translation of this article from following page.
    http://www.mikroproje.com/Blog/tabid/144/articleType/ArticleView/articleId/128/Ortam-De287i351kenleri-Environment-Variables.aspx

    Comment by Saman Sadeghi 2007-05-11 09:47:55

    MyAvatars 0.2

    Cool, thanks!

     
     
    MyAvatars 0.2

    [...] Google X Saman’s Big Ole List Of Windows Environmental Variables [...]

     
    Comment by tony 2007-10-03 11:23:46

    MyAvatars 0.2

    Great list! Although, you did misspell %LOGONSERVER% (you forgot the first “R”)

    Comment by Saman Sadeghi 2007-10-04 13:43:44

    MyAvatars 0.2

    :shock: Crap - thanks dude!

    It’s fixed now!

     
     
    Comment by Scott Lyons 2007-11-27 19:23:57

    MyAvatars 0.2

    Found one more for you:

    %PROGRAMFILES% -> The default location of Program Files

    Easier than reading it out of the registry.

     

    Leave a Reply

    Name (required)
    E-mail (required - never shown publicly)
    URI
    Your Comment (smaller size | larger size)
    You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> in your comment.
    Speed Linking, May 9, 2007 Create Your Own Windows Environmental Variables Or Edit Existing Ones