Environment variables and preferences

Environment variables can be used in preference items to simplify the configuration of options such as file system paths. These variables can include

  • Standard Windows per-machine environment variables

  • Standard Windows per-user environment variables

  • Environment variables that are specific to Group Policy preferences

In addition, some variables might apply only to certain versions of Windows.

The following is a list of variables that can be processed by preference extensions:

  • %AppDataDir% The current user’s Application Data directory

  • %BinaryComputerSid% The security identifier (SID) of the computer in hexadecimal format

  • %BinaryUserSid% The SID of the current user in hexadecimal format

  • %CommonAppdataDir% The All Users Application Data directory

  • %CommonDesktopDir% The All Users Desktop directory

  • %CommonFavoritesDir% The All Users Explorer Favorites directory

  • %CommonProgramsDir% The All Users Programs directory

  • %CommonStartMenuDir% The All Users Start Menu directory

  • %CommonStartUpDir% The All Users Startup directory

  • %ComputerName% The NetBIOS name of the computer

  • %CurrentProcessId% The numeric identity of the main client process

  • %CurrentThreadId% The numeric identity of the main client thread

  • %DateTime% The current time (UTC)

  • %DateTimeEx% The current time (UTC) with milliseconds

  • %DesktopDir% The current user’s desktop directory

  • %DomainName% The domain name or workgroup of the computer

  • %FavoritesDir% The current user’s Explorer Favorites directory

  • %LastError% The last error code encountered during configuration

  • %LastErrorText% The last error code text description

  • %LdapComputerSid% The SID of the computer in Lightweight Directory Access Protocol (LDAP) escaped binary format

  • %LdapUserSid% The SID of the current user in LDAP escaped binary format

  • %LocalTime% The current local time

  • %LocalTimeEx% The current local time with milliseconds

  • %LogonDomain% The domain of the current user

  • %LogonServer% The domain controller that authenticated the current user

  • %LogonUser% The user name of the current user

  • %LogonUserSid% The SID of the current user

  • %MacAddress% The first detected media access control (MAC) address on the computer

  • %NetPlacesDir% The current user’s My Network Places directory

  • %OsVersion% The operating system, which can be a specific Windows operating system or Unknown

  • %ProgramFilesDir% The Windows Program Files directory

  • %ProgramsDir% The current user’s Programs directory

  • %RecentDocumentsDir% The current user’s Recent Documents directory

  • %ResultCode% The client’s exit code

  • %ResultText% The client’s exit code text description

  • %ReversedComputerSid% The SID of the computer in reversed-byte-order hexadecimal format

  • %ReversedUserSid% The SID of the current user in reversed-byte-order hexadecimal format

  • %SendToDir% The current user’s Send To directory

  • %StartMenuDir% The current user’s Start Menu directory

  • %StartUpDir% The current user’s Startup directory

  • %SystemDir% The Windows system directory

  • %SystemDrive% The name of the drive from which the operating system is running

  • %TempDir% The current user’s Temp directory as determined by Windows API

  • %TimeStamp% The time stamp of the configurations being implemented

  • %TraceFile% The path/name of the trace file

  • %WindowsDir% The Windows directory

The above tip was excerpted from Mitch Tulloch’s book Training Guide: Installing and Configuring Windows Server 2012 from Microsoft Press.

Mitch is a nine-time recipient of the Microsoft Most Valuable Professional (MVP) award and a widely recognized expert on Windows administration, deployment and virtualization.  For more information see http://www.mtit.com.

About The Author

Leave a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Scroll to Top