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%

and

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

Don't know what windows version you use or about other windows versions but in XP it's HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment and HKCU\Environment
– barlopSep 19 '12 at 11:06

suppose you do for example C:\>reg query HKCU\Environment <ENTER> or rather C:\>reg query HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment <ENTER> Then does it show the environment variable has been changed at that registry location?
– barlopSep 19 '12 at 11:08

I would just reinstall your operating system. Of course I don't see the problem, %WINDIR% is suppose to point to the Windows directory is it not? Both variables are suppose to point to C:\Windows
– RamhoundSep 19 '12 at 11:29

1

You changed the value to C:\windows and it did not solve your problems? Maybe this is not what causes your problems then?
– LanghardSep 19 '12 at 11:38

2 Answers
2

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%

ok this fixed it. In my frustration/stupidity I must have modified the type of the windir reg key to REG_SZ. After re-creating it as an REG_EXPAND_SZ,setting it to %SystemRoot% and restarting %windir% resolved correctly and my shortcuts work again. Thanks a mil for this
– prayingpantisSep 19 '12 at 14:40

Btw it seems I created an SystemRoot key in the ControlSet002 folder as well when I made this bugger-up, prob in some hope to resolve the problem..so I removed when I re-created the windir key.
– prayingpantisSep 19 '12 at 14:43

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

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.

Actually most likely the default value is C:\Windows, which HAPPENS TO BE the same as %systemroot%. I don't think the value is %systemroot%. The questioner makes it look like that, and so do you now, but I don't think that's the case at all. Look at the comments to his question e.g. from me about xp, or from avirk on windows 7
– barlopSep 19 '12 at 11:51

see the image i attached. (Sorry it is in german) When you double-click on the windir-value in system enviroment variables you can see the set value is in fact: %SystemRoot%. But you have to doubleclick it, otherwise you just see the resolved value.
– LanghardSep 19 '12 at 11:54