Windows - Environment Variable

About

An environment variable is an operating system variable that use the hosted application to set application parameters.

They can be set on different scopes:

  1. for a shell thread in a DOS command
  2. for a specific user
  3. global for a system

Articles Related

How to set a environment variable ?

In a DOS command

set PATH=%PATH%;C:\NiewDirectory\AndSubDirectory;

In a DOS command, the value is only available for this shell/window. Once the DOS windows/command is closed, the modified value is no more applied.

With the Windows GUI

  • Start / Control Panel / (Performance and Maintenance for XP) / System
  • In the Advanced tab, click the Environment Variable button
  • You can enter a environment variable for:
  • a user session
  • of for the complete system (also known as a global environment variable)

How to read a environment variable ?

From a command dos

Open a Command Prompt and tape echo %ENVIRONMENT_VARIABLE_NAME%.

Example

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
 
C:\>echo %TEMP%
C:\DOCUME~1\NICOLA~1.GER\LOCALS~1\Temp

Example of environment variable

%PATH% list of directories where the OS search to find executable binary
%temp% Temp Directory
%SYSTEMDRIVE% Disk Drive
  • Bookmark "Windows - Environment Variable" at del.icio.us
  • Bookmark "Windows - Environment Variable" at Digg
  • Bookmark "Windows - Environment Variable" at Ask
  • Bookmark "Windows - Environment Variable" at Google
  • Bookmark "Windows - Environment Variable" at StumbleUpon
  • Bookmark "Windows - Environment Variable" at Technorati
  • Bookmark "Windows - Environment Variable" at Live Bookmarks
  • Bookmark "Windows - Environment Variable" at Yahoo! Myweb
  • Bookmark "Windows - Environment Variable" at Facebook
  • Bookmark "Windows - Environment Variable" at Yahoo! Bookmarks
  • Bookmark "Windows - Environment Variable" at Twitter
  • Bookmark "Windows - Environment Variable" at myAOL
 
windows/environment_variable.txt · Last modified: 2010/10/11 15:11 by gerardnico