What Is %windir%? Windows Environment Variables Explained (With a List)
%windir% is a Windows environment variable that holds the path of the Windows folder on the system drive, which is usually C:\Windows . The percent signs tell Windows to swap the name for its value, so typing %windir%\System32 in the Run box opens C:\Windows\System32 . %SystemRoot% points to the same folder. Environment variables like these let scripts, installers and tutorials refer to folders…
What Is %windir%? Windows Environment Variables Explained (With a List)
Environment variables are named pieces of text that Windows provides to every program it launches. Each running process inherits a collection of NAME=value pairs, known as an environment block. Windows supports two types of variables: user variables, set for individual users, and system variables, applicable to all users on the system. Child processes inherit the environment of their parent process.
The %windir% variable points to the Windows folder on the system drive, typically C:\Windows. It serves as a convenient reference for scripts, installers, and tutorials, allowing them to refer to folders without hard-coding drive letters or user names. %SystemRoot% points to the same folder, and both exist to maintain compatibility between older DOS-based Windows versions and the Windows NT family.
Common folders under %windir% include:
- %windir%\System32: Core 64-bit system programs and libraries
- %windir%\SysWOW64: 32-bit system files on 64-bit Windows
- %windir%\System32\drivers\etc: The hosts file, mapping names to IP addresses
- %windir%\Temp: Temporary files used by the system and services
- %windir%\Fonts: Installed fonts
- %windir%\Logs: Various Windows log files
Some frequently used environment variables include:
- %windir% / %SystemRoot%: C:\Windows
- %SystemDrive%: C: (system variable)
- %ProgramFiles%: C:\Program Files (system variable)
- %ProgramFiles(x86)%: C:\Program Files (x86) on 64-bit Windows (system variable)
- %ProgramData%: C:\ProgramData (application data for all users) (system variable)
- %ALLUSERSPROFILE%: C:\ProgramData (system variable)
- %USERPROFILE%: C:\Users\mahir (user variable)
- %APPDATA%: C:\Users\mahir\AppData\Roaming (user variable)
- %LOCALAPPDATA%: C:\Users\mahir\AppData\Local (user variable)
- %TEMP% / %TMP%: C:\Users\mahir\AppData\Local\Temp (user variable)
- %USERNAME%: mahir (user variable)
- %COMPUTERNAME%: The PC's name (system variable)
- %PATH%: A semicolon-separated list of folders (user and system values combined)
- %COMSPEC%: C:\Windows\System32\cmd.exe (system variable)
To view or modify environment variables, open the Command Prompt and use the set command. For example, echo %windir% displays the current %windir% value. User-defined variables can be up to 32,767 characters long, and names are case-insensitive on Windows. Environment variables play a crucial role in managing file paths, application data locations, and system configurations in the Windows operating system.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.