- Most Recent Articles on MrTweak.com
- Free Trial of Exchange Server 2007, Hosted by Microsoft and Unisys
- Stop Expiration of HP Inkjet Printer Cartridges
- Dugg or Slashdotted: Why Shared Web Hosting is a Scam
- MrTweak.com Server Transfer - Excuse Any Downtime
Posted Windows Scripting, Windows Desktop Fixes, Windows 2003 Server, Windows 2000 Server on Thursday, May 19th, 2005.
From a command window, DOS script, or any other shell code the Windows environment variables in the list below can be referenced by adding a “%” before and after the variable name. All of these values are returned as strings. The values can be piped (the “>” command in a “DOS window”) to text files or used in other scripting languages. Also, here are detailed descriptions of some of the more common environment variables.
For example, to find the user profile folder and write it to a textfile:
- Open a command console (”cmd” at the Run… prompt).
- Type “echo %userprofile% > C:\file.txt” and press Enter. The path to that resource will be printed to screen. (Without the “> C:\file.txt” the value is printed to a line in the command window)
- Open the C:\file.txt file and the path to the currently logged on user’s profile will be listed.
Semi-complete* Windows Environment Variable List
- ALLUSERSPROFILE
- APPDATA
- CD
- CLIENTNAME
- CLUSTERLOG (probably only on Windows Server clusters)
- CMDCMDLINE
- CMDEXTVERSION
- COMMONPROGRAMFILES
- COMPUTERNAME
- COMSPEC
- DATE
- ERRORLEVEL
- FP_NO_HOST_CHECK (only with FrontPage installed?)
- HOMEDRIVE
- HOMEPATH
- HOMESHARE
- LOGONSEVER
- NUMBER_OF_PROCESSORS
- OS
- PATH
- PATHEXT
- PROCESSOR_ARCHITECTURE
- PROCESSOR_IDENTFIER
- PROCESSOR_LEVEL
- PROCESSOR_REVISION
- PROGRAMFILES
- PROMPT
- RANDOM
- SYSTEMDRIVE
- SYSTEMROOT
- TEMP or TMP
- TIME
- USERDOMAIN
- USERNAME
- USERPROFILE
- WINDIR
* These are all I could remember or dig up from the one book I looked in. Please add more in the article comments & I’ll add them to the list. Thanks to ByteHead for four recent additions.
4 Responses to “Windows Environment Variables List: Paths to System Folders, User Folders, and Useful Values”
Comment on this post below
You can leave a response, or trackback from your own site.
[…] ith a particular Outlook user account. On Windows XP desktops these files are typically in %userpro […]
CLIENTNAME
ClusterLog
CommonProgramFiles
FP_NO_HOST_CHECK (FrontPage I assume)
Thanks for the additions. They’ve been added to the main list.
[…] The Recovery Console is an incredibly powerful tool at times when a Windows system boots straight into a blue screen (of death) error or viruses/spyware have even made the system unusable in safe mode. Unfortuantely it’s hard to use for several reasons. Firstky, Microsoft doesn’t, to my knowledge, provide complete documentation for the Recovery Console anywhere. Also, the Recovery Console is a command-line-only interface that’s unfamiliar to most Windows users and even many non-Linux IT staff. Finally, the commands available in this environment are fewer and slightly different from those in a typical Windows shell environment. […]