Friday, July 3, 2009

DevTnT 8 – Defining an Environment Variable as a File Path

An environment variable is a dynamic value loaded into the memory that can be used by several programms in parallel. In Windows, the environment variables are placed between the "%" character. Thus to display the value of an environment variable, simply type following type of command:


Examples for often used environment variables are: %PATH%, %TEMP%, %USERNAME% and %WINDIR%

For defining a variable as a file path inside a command window you can use the following shell command

set VariableName=value

or use the System Properties for global definition:


You must be an administrator to modify a system environment variable. System environment variables are defined by Windows and apply to all computer users. Any user can add, modify, or remove a user environment variable. The changes are written to the registry, and are usually effective immediately

After applying your changes you can refer to this variable by entering %pp%. E.g.


The only limitation under Windows we know is that file dialogs in SQL Server Management Studio 2005 do not support it.

A nice usage Paul likes: saving downloads from the internet or other temporary files/folders to the sytem temp directory by typing %TEMP%.

No comments:

Post a Comment