What is difference between %Windir% and %Systemroot% in Windows Path Location?
Both of them show "Windows" folder location.
Windows 7 Path – Difference Between %WinDir% and %SystemRoot%
pathwindows 7
Related Question
- Windows – the difference between “Program Files” and “Program Files X86”
- Windows cannot find %windir%\System32\msdt.exe
- Windows – What’s the difference between Processor and Processor Information in PerfMon counters
- Windows – What’s the difference between ‘C’ and ‘CE’ functions on Windows calculator
- Windows – Powershell systemroot in $env:path different when AC elevated
Best Answer
To expand upon Mr. Dave’s answer,
%SystemRoot%
is a built-in variable (along with a small handful of others like%SystemDrive%
). That is, it is not actually defined in the environment variable store atHKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
in the registry.On the other hand,
%windir%
is a regular variable and is defined in the variable store as%SystemRoot%
. (There is no “real variable” counterpart to%SystemDrive%
.)Which to use doesn’t really matter, but you may run into problems with variable expansion in batch-files, in which case you could try the other one. (I don’t recall having problems with this specifically, but it’s worth keeping in mind.)
In addition,
%SystemRoot%
(and%SystemDrive%
) are set during the installation process (when you choose the destination drive) and is thus available from the earliest point when Windows is being installed whereas%windir%
is set at a later point during the install, so if you are creating some sort of custom installation (e.g., OEM, PE, etc.), you will want to use%SystemRoot%
.