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:
1. Open a command console (”cmd” at the Run… prompt).
2. 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)
3. Open the C:\file.txt file and the path to the currently logged on user’s profile will be listed.
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
0 comments:
Post a Comment