Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

and

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

share|improve this question
    
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 – barlop Sep 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? – barlop Sep 19 '12 at 11:08
1  
and for me, (xp), %windir% gives c:\windows and %systemroot% gives c:\windows – barlop Sep 19 '12 at 11:09
    
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 – Ramhound Sep 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? – Langhard Sep 19 '12 at 11:38
up vote 4 down vote accepted

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

share|improve this answer
    
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 – prayingpantis Sep 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. – prayingpantis Sep 19 '12 at 14:43
    
@prayingpantis Glad I could help! – wmz Sep 19 '12 at 14:45

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.

share|improve this answer
1  
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 – barlop Sep 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. – Langhard Sep 19 '12 at 11:54
1  
heh you're right XP too..(double click shows %systemroot%) and looking in the registry with reg.exe, shows windir REG_EXPAND_SZ %SystemRoot% – barlop Sep 19 '12 at 12:25
    
@Riscie: I added an English version for you ;) – Oliver Salzburg Sep 19 '12 at 12:53
    
Thx sir! :) @OliverSalzburg – Langhard Sep 19 '12 at 13:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .