You are on page 1of 7

Windows System Environment Variables

These system environment variables are automatically created by Windows up


on boot-up in Windows Registry key HKEY_LOCAL_MACHINE\ SYSTEM\ CurrentControlSet
\ Control\ Session Manager\ Environment
Variable Sample Typical Value
%SystemDrive% C:
%SystemRoot% C:\WINDOWS
C:\WINNT
%WinDir% C:\WINDOWS
C:\WINNT
%SystemDirectory% C:\WINDOWS\System32
C:\WINNT\System32
%ComSpec% C:\WINDOWS\system32\cmd.exe
The path including the command interpreter program.
%programfiles% C:\WINDOWS\Program Files
%Temp% C:\Users\W\AppData\Local\Temp on Windows Vista & 2008
C:\DOCUME~1\Usr\LOCALS~1\Temp (compressed form of)
C:\Documents and Settings\Usr\Local Settings\Temp
%Tmp%
%HOMEDRIVE% C: The drive letter associated with the user's home dire
ctory
%HOMEPATH% The path to the user's home directory as defined in UMD/
AD (excluding drive):
\Users\<USERNAME> on Windows Vista & 2008
\Documents and Settings\Guest on Windows XP
%OS% Windows_NT (even on Windows Vista & XP machines
The operating system the user is running
%USERDOMAIN% The name of the domain that contains the user's account.
On a stand-alone machine, the same as the machine name.
%USERNAME% The user's name
%USERPROFILE% C:\Users\<USERNAME> — The user's root folder
%USERPROFILE%\Desktop The user's desktop folder
tool If you have the permissions, invoke, then open my DOS batch file 1env
vars.bat which lists the values of these variables on your computer
Reminder Windows resolves commands typed in the start/run box first from f
iles in %SYSTEMDRIVE%, then files in %SYSTEMROOT%. This is regardless of the sys
temdrive (such as E:) being later in the path. This means that a rogue file can
be invoked instead of a good file (such as cmd.exe) if it's in the %SYSTEMDRIVE%
.
Below are dynamic environment variables:
Go to Top of this page.
Previous topic this page
Next topic this page
Variable Sample Typical Value
%CD% The current directory.
%DATE% Current date in the format set by the Date command
%TIME% Current time in the format set by the Time command
%ERRORLEVEL% A number defining exit status of a previous command or c
alled executable.
%RANDOM% A random number between 0 and 32767.
You can quickly reach the folder specified within an environment variable
by typing that variable on the Address bar of Windows Explorer:
Set this at top of window. User Environment Variables Added by Applications
User environment variables are stored in Windows Registry HKEY_CURRENT_USE
R\Environment
Within a command batch file, to list Oracle Environment Variablesanother p
age on this site
echo ORACLE_SID = %ORACLE_SID%
echo ORACLE_HOME = %ORACLE_HOME%
echo ORA_NLS = %ORA_NLS%
echo.
echo PATH = %PATH%
echo.
echo Machine Name to messenger service:
net name
Novell adds these environment variables during installation.
Variable
%USER%
%NWUSERNAME%
%NWLANGUAGE%
Go to Top of this page.
Previous topic this page
Next topic this page
Set this at top of window. Creating Variables on Windows
Environment Variables can be created and changed using several mechanisms:
1. By Windows automatically upon boot-up.
2. By application programs using Windows OS API functions. This is comm
only done by application installation programs.
3. Manually using GUI in System Properties, Advanced tab, Environment V
ariable button. Get to this one of two ways: System Properties tabs
a). right-click My Computer icon, select Properties,
b). click Start > Control Panel > System icon
Click the Advanced tab, New for a new variable or Edit for an existi
ng variable listed.
System Variable Input dialog
reminder System variables are available to all users.
4. Manually using commands typed into the DOS Command Window obtained o
ne of two ways:
a). click Programs | Accessories | Command Prompt
b). click Run..., type cmd and press Enter.
To see all variables, type:
SET
Windows uses a tilde ~ character to substitute for parts of fi
le and folder names longer than 8 characters.
To use the SET command to define a single variable:
SET CLASSPATH=.;path1
The dot specifies the current directory. The semicolon separates two
folders. If the variable was already established, this will replace its value.
To add a value in front of the existing value, refer to itself:
SET CLASSPATH=path1;%CLASSPATH%
caution Variables created with SET are only valid for the current se
ssion and will not be available after the command window is closed or the comput
er reboots.
5. By commands executed from within an AUTOEXEC.BAT file or host script
fileanother page on this site
tool run this sample logon.bat file. (Click Open when prompted. Your
firewall may -- rightfully -- block this.)
Go to Top of this page.
Previous topic this page
Next topic this page
Set screen MS PATH
Forest Path in Winter at the New York Botanical Garden Forest
Reminder The operating system looks for executables down the list of folde
rs listed in the PATH User variable. The operating system uses the first occuran
ce it finds. So watch out for multiple versions of the same program. For example
, the Oracle install automatically adds:
Program Files\Oracle\JRE\1.1.7\Bin;
To enable command line invocation of compiler program csc.exe of the Micro
soft .NET Framework, add this to the end of your PATH environment variable.
1. Click
2. Right-click on "My Computer" to select Properties.
3. Click the "Advanced" tab.
4. Click the "Environment Variable" button.
5. Scroll down the "System variables" list to the "Path" variable.
6. Double click on "Path"
7. Press the "End" key
8. Type (beginning with a semicolon separator) ;%systemroot%Microsoft.N
ET\Framework\v1.1.4322
9. Click "OK"
10. Click "OK" to close the System Properties window.
Verify the change:
1. Click
2. Click Run... for a Run window.
3. Type "cmd" in the Open: field.
4. Click "OK"
5. Type a command such as "csc"
6. You are unsuccessful if you get back a response such as
'csc' is not recognized as an internal or external command,
operable program or batch file.
To spare its users, most commercial applications provide an installer whic
h does this automatically. For example, Microsoft .NET Framework SDK has a vcvar
s32.bat file to update paths on Windows 9x machines.
Reminder Avoid spaces in path names (for backward compatibility and to avo
id trouble) by using the 8 character equivalents.
For example, to reach
C:\Program Files\Mercury Interactive\Mercury LoadRunner\bin specify
C:\PROGRA~1\MERCUR~1\MERCUR~1\bin
The sequence in my PATH:
1. C:\PROGRA~1\Java\jdk1.5.0_02\bin;
2. C:\PROGRA~1\MERCUR~1\MERCUR~1\classes;
3. %SystemRoot%\system32;
4. %SystemRoot%;
5. %SystemRoot%\System32\Wbem;
6. %systemroot%\Microsoft.NET\Framework\v1.1.4322;
7. C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;
8. c:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin;
9. c:\program files\microsoft platform sdk for windows xp sp2\include

Go to Top of this page.


Previous topic this page
Next topic this page
Set this at top of window. UNIX Environment Variables
In UNIX/Linux systems, to list environment variables:
env
In UNIX/Linux systems, add a dollar sign ($) in front of each variable nam
e in all caps:
echo $LOGNAME user name used for login
echo $USER user name (sudo)
echo $UID user name Solaris
echo $SHELL directory containing OS shell executables
echo $PATH directories containing executables, searched to find app
lications when no absolute path is specified on the command line.
echo $LD_LIBRARY_PATH path to system and user libraries
echo $MANPATH directory containing manuals
echo $HOME directory of user's home directory
echo $TZ time zone, such as "US/Mountain"
Reminder In UNIX systems, the colon (:). In Windows systems, the semi-colo
n (;) is used. So to list each path in a separate line:
echo $PATH | tr ':' '\n'
Solaris systems have additional ones, including:
echo $BASH path to the shell on the file system.
echo $HOSTNAME name of the current system.
echo $PPID parent process ID
echo $WINDOWMANAGER name of the X11 window manager
echo $COLUMNS The column width for the terminal
echo $DISPLAY The display variable used for X11 graphics.

Go to Top of this page.


Previous topic this page
Next topic this page
Set screen Creating Variables on Linux
To update an environment variable that lives until the next reboot:
#export PATH= /usr/local/XXX/bin:$PATH
#echo $PATH
Notice that colons are used to separate path items.
To create an environment variable that lives forever, update your .bash_pr
ofile file:
XXXPATH= /usr/local/XXX/bin
export XXXPATH
For a list of environment settings (arguments) for a process with PID 2314
1 (on Solaris):
pargs -ae 23141
Go to Top of this page.
Previous topic this page
Next topic this page
Set this at top of window. Java Environment Variables
JDK versions 1.2 and 1.3 require variables Xrunmic_supp and Xbootclasspath
%mic_class%
Caution! The Java interpreter searches the PATH for a class by name and lo
ads the first one it finds. So specify your own library and the most recent libr
ary first (especially if you use the same name as a class in a standard library)
.
Performance tuning tip Also, for best performance, place the most-often us
ed libraries at the front of the path. This applies to LIBPATH and LD_LIBRARY_PA
TH variables for most often used JNI libraries.
webpage article Java 1.4 Documentation on Classpath notes that the preferr
ed method for command-line tools such as java, javac, or javadoc is to NOT use e
nvironment variables but instead specify -classpath as part of the command invok
ing a Java program.
Reminder The System environment variable CLASSPATH must be in upper case (
not “classpath”). CLASSPATH is used to specify the full path and file name of every
jar file used by java programs. Thus CLASSPATH could be quite long.
C:\jdk1.3.1_01\src.jar;
C:\jdk1.3.1_01\lib\dt.jar;
C:\jdk1.3.1_01\lib\tools.jar;
C:\jdk1.3.1_01\jre\lib\il8n.jar;
C:\jdk1.3.1_01\jre\lib\jaws.jar;
C:\jdk1.3.1_01\jre\lib\rt.jar;
C:\jdk1.3.1_01\jre\demo\sound\JavaSound.jar;
C:\jdk1.3.1_01\demo\jfc\SwingSet2\SwingSet2.jar;
C:\jdk1.3.1_01\demo\jfc\SwingApplet\SwingApplet.jar;
Sun's JDK adds:
C:\jdk1.3.1_01\;
C:\jdk1.3.1_01\Bin;
C:\jdk1.3.1_01\Lib;
Reminder A common mistake with CLASSPATH is to specify only folder paths a
nd leave out jar file names. Semicolons should separate each jar file specificat
ion.
On client machines, Microsoft's VM CLASSPATH is, by default:
%windows%\Java\Classes\Classes.zip;
This string is stored in environment variable CLASSPATH or Windows registr
y key
HKLM\Software\Microsoft\Java VM\Classpath
Windows 95/98 computers should limit CLASSPATH to less than 400 characters
.
Dick Baldwin notes in his tutorial that if you want the CLASSPATH to point
to class files that belong to a package, you should specify a path name that in
cludes the path to the directory one level above the directory having the name o
f your package.
For example, suppose you want the Java interpreter to be able to find clas
ses in the package mypackage. If the path to the mypackage directory is C:\java\
MyClasses\mypackage, you would set the CLASSPATH variable as follows:
set CLASSPATH=C:\java\MyClasses
The purpose of the package directive is to identify a particular class (or
group of classes contained in a single source file (compilation unit)) as belon
ging to a specific package.
NOTE: Training connection also offers some great tutorials on Java program
s, Dreamweaver training, and Flex software.
In Linux: pCLASSPATH=/usr/local/java/jre/bin
My CLASSPATH:
1. C:\PROGRA~1\MERCUR~1\MERCUR~1\classes;
2. C:\PROGRA~1\MERCUR~1\MERCUR~1\classes\srv;
3. C:\PROGRA~1\Java\jdk1.5.0_02\lib\rt.jar
Go to Top of this page.
Previous topic this page
Next topic this page
Set this at top of window. Amazon EC2 File Paths
Amazon EC2 command script users add these environment variables. For examp
le, if EC2 files are located in folder C:\EC2:
Variable Sample
EC2_HOME C:\EC2 where files are located
EC2_PRIVATE_KEY C:\EC2\pk.pem full path to file
EC2_CERT C:\EC2\509cert.pem full path to file
Go to Top of this page.
Previous topic this page
Next topic this page
Set this at top of window. Windows Network Shares
Changes to variables disappear after reboot.
So change the variables in a shell script or Windows network share. This m
apdir.bat is an example of allocating the X: drive.
...
This assumes that the loopback IP address has not been changed in the host
s file.

You might also like