📅 2023-Mar-20 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ environment variables, windows ⬩ 📚 Archive
Windows has several default environment variables for values and paths. I prefer to use these environment variables instead of the absolute paths in commands, scripts and programs. This is because using variables makes the usage portable and agnostic and works the same no matter who is the user or the system it is used on.
set
command to see the list of environment variables and their values.echo
command to print the value of a specific environment variable. For example: echo %PATH%
.For this list of environment variables, I assume a user named archimedes
, a computer named aragon
and a company named acme.com
:
%ALLUSERSPROFILE%
: C:\ProgramData
%APPDATA%
: C:\Users\archimedes\AppData\Roaming
%CD%
: Current directory path.%CMDCMDLINE%
: "C:\Windows\system32\cmd.exe"
%CMDEXTVERSION%
: 2
%COMPUTERNAME%
: aragon
. Name of the computer. This will usually be its hostname too.%COMSPEC%
: C:\Windows\system32\cmd.exe
%CommonProgramFiles%
: C:\Program Files\Common Files
%CommonProgramFiles(x86)%
: C:\Program Files (x86)\Common Files
%CommonProgramW6432%
: C:\Program Files\Common Files
%DATE%
: Sun 03/19/2023
%DriverData%
: C:\Windows\System32\Drivers\DriverData
%ERRORLEVEL%
: 0
%HOMEDRIVE%
: C:
%HOMEPATH%
: \Users\archimedes
%LOCALAPPDATA%
: C:\Users\archimedes\AppData\Local
%LOGONSERVER%
: \\aragon
%NUMBER_OF_PROCESSORS%
: 16
%OS%
: Windows_NT
%OneDrive%
: C:\Users\archimedes\OneDrive
%PATH%
: C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Users\archimedes\AppData\Local\Microsoft\WindowsApps;
%PATHEXT%
: .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
%PROCESSOR_IDENTIFIER%
: Intel64 Family 6 Model 141 Stepping 1, GenuineIntel
%PROCESSOR_LEVEL%
: 6
%PROCESSOR_REVISION%
: 8d01
%PROMPT%
: $P$G
%PSModulePath%
: C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules;C:\Program Files (x86)\Microsoft Azure Information Protection\Powershell
%PUBLIC%
: C:\Users\Public
%ProgramData%
: C:\ProgramData
%ProgramFiles%
: C:\Program Files
%ProgramFiles(x86)%
: C:\Program Files (x86)
%ProgramW6432%
: C:\Program Files
%RANDOM%
: Generate a random number between 0 and 32767.%SystemDrive%
: C:
%SystemRoot%
: C:\Windows
%TEMP%
: C:\Users\ARCHIM~1\AppData\Local\Temp
%TIME%
: 17:57:46.37
%TMP%
: C:\Users\ARCHIM~1\AppData\Local\Temp
%USERDOMAIN%
: acme.com
%USERPROFILE%
: C:\Users\archimedes
%UserName%
: archimedes
%windir%
: C:\Windows