El TecnoBaúl de Kiquenet

Kiquenet boring stories

Environment Variables

Posted by kiquenet en 11 agosto 2014

  • Variable– a term primarily known from programming. A variable is a memory space (storage) for a predefined type of data. A variable always has a name and represents some data or objects. In programming and in the Windows environment, there exist predefined variables that have been set by the creators to be used by the system or the user For example, using a string to the variable %SYSTEMROOT% you will get the path to Windows directory. Besides predefined variables, you can create your own, or they can be created and modified according to the requirements of a program or user. In case of a virus or incorrect variable values the system or program may not work correctly.
  • Environment Variables – predefined variables that are intended for saving system settings or string. Most variables are saved in Windows registry and most of them are set during the installation of the system or upon a user’s or program’s request. In the Windows system, you can either see user variables representing particular settings of each user or system variables intended for the system and all users. You can recognize the variable environment very easily – there is the "percentage" (%) character in front and behind the variable (%Variable%).

Variable management

  • Right click the icon Computer – Properties – Advanced – Environment Variables

Environment Variables

By marking a variable or using buttons you can add, modify or remove some variables

edit environment variables

Example of editing the "windir" variable after clicking the Edit button.

  • TIP: If we want to add a new variable MW in user variables with the value c:\MUJWEB, you can go to Start – Run and type %MW% to open a window with the content of the c:\MUJWEB directory.
  • Displaying and editing in the command line using the "set" command

C:\set
ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\adminxp\AppData\Roaming
CommonProgramFiles=C:\Program Files\Common Files
COMPUTERNAME=ADMINXP-PC
ComSpec=C:\Windows\system32\cmd.exe
FP_NO_HOST_CHECK=NO
HOMEDRIVE=C:
HOMEPATH=\Users\adminxp
LOCALAPPDATA=C:\Users\adminxp\AppData\Local
LOGONSERVER=\\ADMINXP-PC
OS=Windows_NT
Path=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PROCESSOR_ARCHITECTURE=x86
PROCESSOR_IDENTIFIER=x86 Family 15 Model 79 Stepping 2, AuthenticAMD
PROCESSOR_LEVEL=15
PROCESSOR_REVISION=4f02
ProgramData=C:\ProgramData
ProgramFiles=C:\Program Files
PROMPT=$P$G
PUBLIC=C:\Users\Public
SystemDrive=C:
SystemRoot=C:\Windows
TEMP=C:\Users\adminxp\AppData\Local\Temp
TMP=C:\Users\adminxp\AppData\Local\Temp
USERDOMAIN=adminxp-PC
USERNAME=adminxp
USERPROFILE=C:\Users\adminxp
windir=C:\Windows

Example of displaying the settings of some system variables in the command line using the "set" command. For help, use the command "set /?".

To display particular variables, even those that are not visible after using the "set" command, you can use the "echo" command. E.g. echo %ALLUSERSPROFILE%

To modify, use the syntax SET [variable=[string]] – e.g. SET MW=C:\MUJWEB

  • Some values can be changed directly in the registry or through graphical environment and system tools or using other applications.
  • Changes can be made through login scripts or other scripts and batch commands (autoexec.bat in older systems).

List of primary variables of Windows Vista and Windows XP

%ALLUSERSPROFILE%
Path to the All User profile
Vista – C:\ProgramData
WindowsXP – C:\Documents and Settings\All Users

%APPDATA%
Path to the Application Data folder
Vista – C:\Users\%USERNAME%\AppData\Roaming
WindowsXP – C:\Documents and Settings\%USERNAME%\Application Data

%CD%
Path to the current directory.

%CMDCMDLINE%
Path to the launched operation in the Command Line / Cmd.exe program (C:\WINDOWS\system32\cmd.exe)

%CMDEXTVERSION%
Version number of the current Command Processor Extensions

%commonprogramfiles%
Path to the Common Files folder (Ex. C:\Program Files\Common Files)

%COMPUTERNAME%
Computer name

%COMSPEC%
Path to the command interpreter

%DATE%
Current date

%ERRORLEVEL%
Error code for the last used command (0 means OK)

%HOMEDRIVE%
Current home drive letter (according to the home directory)

%HOMEPATH%
Full path to the user’s home folder.

%HOMESHARE%
Full network path to the user’s home folder.

%LOCALAPPDATA%
(ex. C:\Users\%USERNAME%\AppData\Local)

%LOGONSERVER%
Name of the domain controller that validated the domain logon. If the domain is not available, name of the computer is displayed.

%NUMBER_OF_PROCESSORS%
Number of processors in the computer

%OS%
Name of the OS family (ex. Windows_NT – the same for XP and Vista)

%PATH%
Path to executable files. (if you define an executable program, it is launched without the need of specifying the full path).

%PATHEXT%
File types that are set as executable in the operating system.

%PROCESSOR_ARCHITECTURE%
Processor’s architecture. (x86, IA64)

%PROCESSOR_IDENTFIER%
Processor’s description.

%PROCESSOR_LEVEL%
Processor’s model number

%PROCESSOR_REVISION%
Version number of the processor’s hardware

%ProgramData%
New in Vista (ex. C:\ProgramData). The same as %ALLUSERSPROFILE%.

%PROGRAMFILES%
Path to the Program Files directory. (ex. C:\Program Files)

%PROMPT%
Setup of the current command intepreter (e.g. $P$G, more with "prompt /?")

%PUBLIC%
Represents the public folder for shared data (data which must be visible for all users within a computer or network). Newly in Vista (C:\Users\Public).

%RANDOM%
Generates a random decimal number within the range from 0 to 32767.

%SYSTEMDRIVE%
Denotes the drive that contains the root directory of the Windows system (ex. c:)

%SYSTEMROOT%
Location of the root directory of the operating system.

%TEMP% a %TMP%
Folder for temporary data. Some applications invoke the folder with the variable %TMP%, others use %TEMP%. (ex. C:\Users\%USERNAME%\AppData\Local\Temp)

%TIME%
Current time

%USERDOMAIN%
Name of the domain that contains the account of the currently logged in user. If the user is not a member of the domain, name of the computer will be displayed.

%USERNAME%
Name of the currently logged in user

%USERPROFILE%
Location of the current user’s profile

%WINDIR%
Location of the operating system directory. %SYSTEMROOT% is a newer variable. %WINDIR% is used by older systems and applications.

Saving data and variables for all users – registry for Windows XP

Key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders

Common AppData
REG_EXPAND_SZ
%ALLUSERSPROFILE%\Application Data

Common Desktop
REG_EXPAND_SZ
%ALLUSERSPROFILE%\Desktop

Common Documents
REG_EXPAND_SZ
%ALLUSERSPROFILE%\Documents

Common Favorites
REG_EXPAND_SZ
%ALLUSERSPROFILE%\Favorites

Common Programs
REG_EXPAND_SZ
%ALLUSERSPROFILE%\Start Menu\Programs

Common Start Menu
REG_EXPAND_SZ
%ALLUSERSPROFILE%\Start menu

Common Startup
REG_EXPAND_SZ
%ALLUSERSPROFILE%\Start Menu\Programs\Startup

Common templates
REG_EXPAND_SZ
%ALLUSERSPROFILE%\Templates

Saving data and variables for all users – registry for Windows Vista

Key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\explorer\User Shell Folders

Common AppData
REG_EXPAND_SZ
%ProgramData%

Common Desktop
REG_EXPAND_SZ
%PUBLIC%\Desktop

Common Documents
REG_EXPAND_SZ
%PUBLIC%\Documents

CommonMusic
REG_EXPAND_SZ
%PUBLIC%\Music

CommonPictures
REG_EXPAND_SZ
%PUBLIC%\Pictures

Common Programs
REG_EXPAND_SZ
%ProgramData%\Microsoft\Windows\Start Menu\Programs

Common Start Menu
REG_EXPAND_SZ
%ProgramData%\Microsoft\Windows\Start Menu

Common Startup
REG_EXPAND_SZ
%ProgramData%\Microsoft\Windows\Start Menu\Programs\Startup

Common templates
REG_EXPAND_SZ
%ProgramData%\Microsoft\Windows\Templates

CommonVideo
REG_EXPAND_SZ
%PUBLIC%\Videos

{3D644C9B-1FB8-4f30-9B45-F670235F79C0}
REG_EXPAND_SZ
%PUBLIC%\Downloads

Saving data and variables for all users – registry for Windows XP

Key: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurentVersion\Explorer\User Shell Folders

AppData
REG_EXPAND_SZ
%USERPROFILE%\Application Data

Cache
REG_EXPAND_SZ
%USERPROFILE%\Local Settings\Temporary Internet Files

Cookies
REG_EXPAND_SZ
%USERPROFILE%\Cookies

Desktop
REG_EXPAND_SZ
%USERPROFILE%\Desktop

Favorites
REG_EXPAND_SZ
%USERPROFILE%\Favorites

History
REG_EXPAND_SZ
%USERPROFILE%\Local Settings\History

LocalAppData
REG_EXPAND_SZ
%USERPROFILE%\Local Settings\Application Data

Local Settings
REG_EXPAND_SZ
%USERPROFILE%\Local Settings

My Pictures
REG_EXPAND_SZ
%USERPROFILE%\My Documents\My Pictures

NetHood
REG_EXPAND_SZ
%USERPROFILE%\NetHood

Personal
REG_EXPAND_SZ
%USERPROFILE%\My Documents

PrintHood
REG_EXPAND_SZ
%USERPROFILE%\PrintHood

Programs
REG_EXPAND_SZ
%USERPROFILE%\Start Menu\Programs

Recent
REG_EXPAND_SZ
%USERPROFILE%\Recent

SendTo
REG_EXPAND_SZ
%USERPROFILE%\SendTo

Start Menu
REG_EXPAND_SZ
%USERPROFILE%\Start Menu

Startup
REG_EXPAND_SZ
%USERPROFILE%\Start Menu\Programs\Startup

Templates
REG_EXPAND_SZ
%USERPROFILE%\Templates

Saving data and variables for all users – registry Windows Vista

Key: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders

AppData
REG_EXPAND_SZ
%USERPROFILE%\AppData\Roaming

Cache
REG_EXPAND_SZ
%USERPROFILE%\AppData\Local\Microsoft\Windows\Temporary Internet Files

Cookies
REG_EXPAND_SZ
%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Cookies

Desktop
REG_EXPAND_SZ
%USERPROFILE%\Desktop

Favorites
REG_EXPAND_SZ
%USERPROFILE%\Favorites

History
REG_EXPAND_SZ
%USERPROFILE%\AppData\Local\Microsoft\Windows\History

LocalAppData
REG_EXPAND_SZ
%USERPROFILE%\AppData\Local

My Music
REG_EXPAND_SZ
%USERPROFILE%\Music

My Pictures
REG_EXPAND_SZ
%USERPROFILE%\Pictures

My Video
REG_EXPAND_SZ
%USERPROFILE%\Videos

NetHood
REG_EXPAND_SZ
%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Network

Personal
REG_EXPAND_SZ
%USERPROFILE%\Documents

PrintHood
REG_EXPAND_SZ
%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Printer

Programs
REG_EXPAND_SZ
%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start

Recent
REG_EXPAND_SZ
%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Recent

SendTo
REG_EXPAND_SZ
%USERPROFILE%\AppData\Roaming\Microsoft\Windows\SendTo

Startup
REG_EXPAND_SZ
%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start

Start Menu
REG_EXPAND_SZ
%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start

Templates
REG_EXPAND_SZ
%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Templates

{374DE290-123F-4565-9164-39C4925E467B}
REG_EXPAND_SZ
%USERPROFILE%\Downloads

References:
http://www.adminxp.com/windowsvista/index.php?aid=235

Anuncios

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s

 
A %d blogueros les gusta esto: