SystemRoot and Windir are two built-in environment variables that point to your Windows directory. Although both are built-in variables, SystemRoot variable is read-only, but Windir variable can can be removed or edited, and its setting is stored in the registry.
If %Windir% is not recognized or resolved by the system, your batch scripts that use the variable would fail to run correctly.
Also, the tasks pane in various places such as Control Panel, and modern Settings app point to application paths referencing
%Windir%. If this variable is broken, clicking those links would cause the following error:
Here is how to fix the problem.
Create or Fix Windir Environment Variable
Press WinKey + R, type sysdm.cpl and press ENTER
From the Advanced tab, and click Environment variables.
In the System variables section, create a new variable by clicking New. If the
Windir variable already exists, double-click to edit the existing one.
Name the variable as
windir, and set the value as
Click OK, OK. Changes are applied instantly. If not, logoff and login back.
Path Length Issue
This problem can also occur if the PATH length exceeds 2048 characters (or 4096 chars in Windows 7 and higher). Make sure you remove unneeded entries from PATH to keep it within the limit. For more information, check out article at Intel’s site: Limitation to the length of the System PATH variable | Intel®.