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 %SystemRoot%
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®.
One small request: If you liked this post, please share this?
One "tiny" share from you would seriously help a lot with the growth of this blog. Some great suggestions:- Pin it!
- Share it to your favorite blog + Facebook, Reddit
- Tweet it!
I don’t Know whatever you have written it’s not working with my System.Please write something else if you have proper solution.
@Ankit Singh: What’s the PATH length?
I can’t go into the variable environment settings, what should I do ?
What about PS, Ramesh?. Your solution works when I enter ‘cmd’ command (as Admin)
but doesn’t as I enter PS (as Admin)….
cd %windir% adds the string to the end of current path and creates non cxisting path…….
ObjectNotFound C:\windows\System32\%windir%….
Regards 🙂