The %SystemRoot% environment variable contains the path to the Windows directory. (e.g. c:\windows
)
SystemRoot
is not configured in Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
, it is automagically set.
Now, typically on Windows 10 this directory has the caseing C:\Windows
on NTFS disk.
After a script test(*) broke, we noticed:
- With same OS version Windows 10 (LTSC 1809 17763.3887)
- Some boxes use
%SystemRoot% == C:\WINDOWS
(all uppercase, despite the directory on-disk beingC:\Windows
) - Some boxes use
%SystemRoot% == C:\Windows
(case of dir on disk) - We cross checked with ProcessExplorer: The casing difference is already present in the environment block of the
wininit.exe
process, so it's not overridden somewhere.
Q:
Is the base for the value of SystemRoot
read from any specific registry key?
What could explain this difference?
(*): To be clear, the test was broken anyway - thou shall not rely on path casing on Windows.
It's set in the boot process. It's not set in the registry, because the OS boot process needs to know where to find the registry files (and other OS files) before it can read them from the registry.
https://learn.microsoft.com/en-us/windows-hardware/drivers/devtest/boot-options-in-windows
On older Windows OS, it's probably in boot.ini