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

7

3

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

prayingpantis

Posted 2012-09-19T10:54:43.100

Reputation: 97

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 – 2012-09-19T11:06:15.967

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 – 2012-09-19T11:08:09.087

1and for me, (xp), %windir% gives c:\windows and %systemroot% gives c:\windows – barlop – 2012-09-19T11:09:49.097

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 – 2012-09-19T11:29:15.977

1You changed the value to C:\windows and it did not solve your problems? Maybe this is not what causes your problems then? – Langhard – 2012-09-19T11:38:58.657

%systemroot% and %windir% resolve to the same destination to C:\Windows on Windows-7 too. – avirk – 2012-09-19T11:40:28.643

echo %windir%does output C:\windows on my machine, not %SystemRoot% – Langhard – 2012-09-19T12:01:10.743

Answers

7

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

wmz

Posted 2012-09-19T10:54:43.100

Reputation: 6 132

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 – 2012-09-19T14:40:48.613

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 – 2012-09-19T14:43:52.847

@prayingpantis Glad I could help! – wmz – 2012-09-19T14:45:32.207

2

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.

Langhard

Posted 2012-09-19T10:54:43.100

Reputation: 560

1Actually 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 – 2012-09-19T11:51:44.507

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 – 2012-09-19T11:54:59.610

1heh you're right XP too..(double click shows %systemroot%) and looking in the registry with reg.exe, shows windir REG_EXPAND_SZ %SystemRoot% – barlop – 2012-09-19T12:25:48.553

@Riscie: I added an English version for you ;) – Der Hochstapler – 2012-09-19T12:53:27.993

Thx sir! :) @OliverSalzburg – Langhard – 2012-09-19T13:34:43.103