Most popular tags

Welcome to, where you can ask questions and receive answers from other members of the community.

WINDIR environment variable resolves to %SystemRoot% and not C:\windows

Some time ago I manually changed the WINDIR environment variable to test something in a legacy program I was working with (should have done this on a VM rather than my desktop :/ but it's too late now)

So for some reason now %WINDIR% does not resolve to c:\windows anymore, but to %SystemRoot%. From the command line:

echo %WINDIR% outputs %SystemRoot%


echo %SystemRoot% outputs C:\windows

Not being able to resolve WINDIR is causing me all sorts of head aches. I've tried setting the value of WINDIR explicitly to c:\windows in that console windows provides, but to no avail. I've also tried manually changing the windir registry key's value at

HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment\windier


HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Control\Session Manager\Environment\windir

But still not luck. Has anyone seen this behavior before?

forgot to mention this is on windows 7 Enterprise ed

1 Answer

Please check the type of the value you have as Windir. You probably inadvertently changed it from REG_EXPAND_SZ to REG_SZ. You have to do it directly in registry (GUI panels will not show you the difference):

Start Registry editor, navigate to HKEY_LOCAL_MACHINE\system\currentControlSet\Control\Session Manager\Environment.
Check that windir has a type of REG_EXPAND_SZ.
If not, re-create the entry to be: windir REG_EXPAND_SZ %SystemRoot%

Logoff/logon and check if it works

Correction! %SystemRoot% is the default value. So this variable is set correct in your system.

enter image description here

Right click on Computer - Settings - Advanced System Settings - Advanced - Enviroment Variables. In the second part of that window (under Enviroment Variables) you can find your variable windir pointing to %systemroot%. Change it to %SystemRoot%, which is the default value and test if you still get errors.