Cannot resolve %windir% / Cannot modify %path% or %path% being reset on boot

45

8

See Updates 3 and 4 below for how the issue has evolved


My computer (Windows 7 x64, Lenovo Thinkpad T530) is having an issue resolving %windir%. After boot-up, everything works fine. At some point a while later, the computer is suddenly unable to resolve %windir%.

Console Window

Checking the environment variables window shows that it is defined.

Environment Varibales

Checking the registry also shows that it is defined as well. I've actually deleted the key and re-entered it to no avail.

Registry

After a reboot, everything works fine for a while. Does anyone have any thoughts on anything else I can check?


Update 1: After thinking about it some, I have uninstalled the Konica Minolta Pagebox driver/program that was installed about the time this problem started happening (see comments below). The problem seems to take about 4-24 hours (I've never timed it) to manifest, so I'll update again after that.

Update 2: Issue is still occurring. I came back from lunch and %windir% cannot be found. I did a test after a reboot this morning and put the computer to sleep, then woke it up. %windir% was still defined after waking up.

Update 3: Per Daniel in the comments, I ran set before and after error and compared the outputs. The first thing I noticed is that on a fresh boot my %path% is 2000+ characters long. I pruned it down to ~375 characters and verified it in a new cmd window. I rebooted, checked the path again, and it was back to over 2000+ characters (it matched what I originally saw). I truncated it again and rebooted once more and the same thing happened. I deleted the path variable and created a new one; same thing happened. At this point all I can conclude is either I cannot permanently change my path OR the path is being reset by some process on boot. Any thoughts?

Update 4: I edited my path via the registry method suggested below. I checked my path today after running for a while and it has grown from what I entered into the registry; it now has a few new entries and a lot of duplicates. The only new entries are from SQL Server 2012. I went to change this in the registry and I noticed that the registry does NOT match the output of echo %path%. Checking the Environment Variables from the Advanced Properties Tab shows a third version of my path.

Registry Path:
C:\Program Files (x86)\Microchip\mplabc30\v3.30\bin;
C:\RUBY193\BIN;
C:\Windows\SYSTEM32;
C:\Windows;
C:\Windows\SYSTEM32\WBEM;
C:\PROGRAM FILES\COMMON FILES\LENOVO;
C:\SWTOOLS\READYAPPS;
C:\PROGRAM FILES (X86)\COMMON FILES\LENOVO;
C:\PROGRAM FILES (X86)\MICROCHIP\MPLAB C32 SUITE\BIN;
C:\HTSOFT\PIC18\BIN;
C:\PROGRAM FILES\TORTOISESVN\BIN;
C:\Windows\System32\WindowsPowerShell\v1.0\;
C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\;
C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\;
C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;
C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\;

Command Line path:
C:\Program Files (x86)\Microchip\mplabc30\v3.30\bin;
C:\RUBY193\BIN;
C:\Windows\SYSTEM32;
C:\Windows;
C:\Windows\SYSTEM32\WBEM;
C:\PROGRAM FILES\COMMON FILES\LENOVO;
C:\SWTOOLS\READYAPPS;
C:\PROGRAM FILES (X86)\COMMON FILES\LENOVO;
C:\PROGRAM FILES (X86)\MICROCHIP\MPLAB C32 SUITE\BIN;
C:\HTSOFT\PIC18\BIN;
C:\PROGRAM FILES\TORTOISESVN\BIN;
C:\Windows\System32\WindowsPowerShell\v1.0\;
C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\;
C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\;
C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;
C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\;
C:\Program Files(x86)\Microchip\mplabc30\v3.30\bin;
C:\RUBY193\BIN;
C:\Windows\SYSTEM32;
C:\Windows;
C:\Windows\SYSTEM32\WBEM;
C:\PROGRAM FILES\COMMON FILES\LENOVO;
C:\SWTOOLS\READYAPPS;
C:\PROGRAM FILES (X86)\COMMON FILES\LENOVO;
C:\PROGRAM FILES (X86)\MICROCHIP\MPLAB C32 SUITE\BIN;
C:\HTSOFT\PIC18\BIN;
C:\PROGRAM FILES\TORTOISESVN\BIN;
C:\Windows\System32\WindowsPowerShell\v1.0\;

Environment Variables path:
C:\Program Files (x86)\Microchip\mplabc30\v3.30\bin;
C:\RUBY193\BIN;
C:\Windows\SYSTEM32;
C:\Windows;
C:\Windows\SYSTEM32\WBEM;
C:\PROGRAM FILES\COMMON FILES\LENOVO;
C:\SWTOOLS\READYAPPS;
C:\PROGRAM FILES (X86)\COMMON FILES\LENOVO;
C:\PROGRAM FILES (X86)\MICROCHIP\MPLAB C32 SUITE\BIN;
C:\HTSOFT\PIC18\BIN;
C:\PROGRAM FILES\TORTOISESVN\BIN;
C:\Windows\System32\WindowsPowerShell\v1.0\;

It looks as though the command line path = registry path + environment variables path. I attempted to set the registry path and the environment variables path to the same thing and reboot. After reboot, my path is now doubled, basically two back-to-back copies of the registry path above.

Once again, any thoughts?

Update 5: After talking with the IT Manager, he says he is fighting a similar issue on another computer. Both computers have SSDs (seems to be the only common factor). This may or may not be pertinent.

Zack

Posted 2013-01-03T19:30:45.040

Reputation: 551

I had a similar problem and cutting down on items in the path solved it for me. – M-Peror – 2014-08-26T15:59:46.557

1

Possible duplicate of Windows 7's PATH and environment variables are corrupted

– jpaugh – 2017-07-28T20:22:08.293

try to use set to assign value to windir manually and repeat with echo again - see if this will give you output or not. If it will then something is messing up with your env variables - if not then something is not ok with your shell and/or echo command. – mnmnc – 2013-01-03T19:41:36.050

Setting it works, but I'm not really sure that that proves anything, as I can run "set SystemRoot=abcd", for a similar, short-lived session variable – Zack – 2013-01-03T19:50:23.480

If I may ask, how did you notice this in the first place? That is to say, what tipped you off that there was a problem? (On the off chance that it's relevant...) – Shinrai – 2013-01-03T21:04:51.577

Some couple of weeks ago, a network scanner driver was installed on my computer. Shortly thereafter, I had issues with windows programs not being found. I tracked it down to my path being too long, and fixed it. This may or may not be related. Things have been quirky since. Specifically, the windows speaker icon in the bottom corner raises an error periodically ("No output driver found", but the sound still works). I went to check the path again, and I got an error trying to get to advanced system settings ("cannot find %windir%\system32..."). I tracked it down to windir not resolving. – Zack – 2013-01-03T21:50:45.993

I see you have programming related ENV variables in the screencaps. Do you have a really long PATH variable? – horatio – 2013-01-04T19:35:57.500

Try typing "set" in a command prompt before this happens & save the result. Then compare to what you get after, to see if any other vars are getting stomped. – Daniel R Hicks – 2013-01-04T19:58:46.190

My path is currently 722 characters long (After the scanner driver was installed path was about 1100 chars long; I trimmed it down) – Zack – 2013-01-04T20:38:21.037

Daniel - I will try that and update when I have a result (probably on monday; this is on work computer) – Zack – 2013-01-04T20:42:53.757

Answers

26

I had the same issue and found this question first. However, the real cause/solution is not mentioned yet in this question, but it is mentioned here: Windows 7's PATH and environment variables are corrupted

Summary of the solution: make sure your path is < 2048 characters. Check in both the user variables and the system variables.

Pieter-Jan Busschaert

Posted 2013-01-03T19:30:45.040

Reputation: 361

4

With the GUI, set your %windir% variable content to %SystemRoot%.

As for your %path%, you may solve this with Registry Editor:

  • Start Regedit.exe
  • Go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
  • In the right pane, double-click on the value Path (REG_EXPAND_SZ)
  • Change the value however you like and reboot

enter image description here

user184745

Posted 2013-01-03T19:30:45.040

Reputation: 151

Having the same problem on a T430 also. – Lightyear Buzz – 2014-07-14T02:00:55.877

NB: Use this answer in conjunction with the above; i.e. when amending the value, ensure it comes in at under 2048 characters (you can copy-paste the value to a text editor (e.g. http://pnotepad.org) to edit it & have the characters counted for you)

– JohnLBevan – 2017-04-16T15:49:18.160

This looks like it fixed it. I'll give it a full day at work on Monday to make sure, and assuming all goes well, I'll mark this as the correct answer after that. Thanks. – Zack – 2013-01-05T22:25:26.927

1@Zack I have the exact same problem on a lenovo T430 and so does a coworker. The above answer did not work. Was the problem eventually solved? – ford prefect – 2013-10-23T18:18:52.560

@inquisitiveIdiot - I never fully resolved it. I uninstalled some stuff that was in the path and kept pruning the path down manually at the command line. Eventually the problem stopped happening. – Zack – 2013-11-12T19:21:16.110

@Zack I just posted what ended up working as an answer in case you have a problem again – ford prefect – 2013-11-12T19:29:39.007

2

I did have the same problem in my Lenovo TS530. It started to occur after installing new programs that caused my path to be even much longer than before and so that the installers added the new stuff into the beginning of path definition. I edited the path in regedt by moving %SystemRoot% into the beginning of the path definition.

path = %SystemRoot%\system32;%SystemRoot%;%SystemRoot....

In addition, I edited enviromental variable windir from

windir= C:/Windows

to

windir=C:\Windows

That seems to have fixed the problem. (It is possible that I did the mistake with backslash earlier while trying to fix the problem. Or alternatively the installer has changed it.)

imppu

Posted 2013-01-03T19:30:45.040

Reputation: 21

Windows is pretty forgiving about using / instead of \. – jpaugh – 2017-07-31T16:01:35.617

1

As already mentioned by @Pieter-Jan Busschaert it's most likely because of a corrupt or too long PATH environment variable.

The easiest way how to fix this is by downloading the Rapid Environment Editor. It shows you what's wrong with your PATH settings and lets you fix it right away.

Dunken

Posted 2013-01-03T19:30:45.040

Reputation: 751

I was always able to fix the path. The problem was that the path kept spontaneously expanding beyond 2048 characters without me having done anything (e.g. installing or uninstalling a program). – Zack – 2016-02-20T05:39:01.817

1

I have found (consistently) that this will also occur if SQL Server 2012 or later versions are installed on the Windows 7 machine (not sure if the issue also occurs on Win8.x or Win10), but the solution I've found is to also create the windir Environment variable under the current user context to be set to %SystemRoot%. The only time we would see this is when RDP'ing (remote session) into the workstation(s). If we logged into the console we would not encounter this at all. I don't know SQL 2012 (or later) components happened to be installed on yours just prior to this happening or not, but you could try this resolution.

Mike Fanning

Posted 2013-01-03T19:30:45.040

Reputation: 11

1

I had the same issue. It was resolved when I deleted the PATH Environment variable (after making a backup of its contents) in the following dialog.

C:\Windows\System32\SystemPropertiesAdvanced.exe

I reconstructed the PATH variable later one by one. I moved part of the PATH contents which did not fit in the System variables into the User variables PATH.

Vijay Vepakomma

Posted 2013-01-03T19:30:45.040

Reputation: 111

0

Please check out the limitation of the path-variable: https://support.microsoft.com/en-us/kb/2685893

grandtheftoli

Posted 2013-01-03T19:30:45.040

Reputation: 1

Could you expand on your answer with relevant quotes from the KB article? Other than that, nice find. – Burgi – 2016-03-30T08:04:42.867

Looks really useful – Zack – 2016-03-30T12:55:33.640

0

Our help desk gave me this response:

  1. Open User Account Control Settings by clicking the Start button , and then clicking Control Panel. In the search box, type uac, and then click Change User Account Control settings.
  2. Do the following: •To turn off UAC, move the slider to the Never notify position, and then click OK. If you're prompted for an administrator password or confirmation, type the password or provide confirmation. You will need to restart your computer for UAC to be turned off.

It works given two different things:

1.) This problem doesn't actually exist because this program requires %windir to be correctly working. Instead run C:\Windows\System32\UserAccountControlSettings in command prompt.

2.) You prefer not having the windows security warnings.

ford prefect

Posted 2013-01-03T19:30:45.040

Reputation: 227

UAC was already disabled in my case, but if this works for you or anyone else, that's great – Zack – 2013-11-12T20:37:20.590

0

I had the same problem after upgrading to an SSD on my Lenovo X230. The software I used for the migration (Acronis TrueImage) had added a path value, which must have pushed me over the limit. I solved it as follows:

Open Regedit

Go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment

Modify the Path value (see the answer from user184745 above).

Cut the current value and pasted into Notepad.

Edited out several duplicate values as well as paths that seemed of little benefit. I reduced the length of the path from 2,283 chars to 1,517.

Pasted the new path string into the Path key.

(Saved the contents of my Notepad just in case.)

Rebooted. All is well.

Robert

Posted 2013-01-03T19:30:45.040

Reputation: 1

-1

I had the same issues as above. %windir%. icons not showing for some items. Any application that used windir... Went through all the fixes including cold boot, path shortening, etc.
Finally recreated my windows profile... problem gone.

PaulG

Posted 2013-01-03T19:30:45.040

Reputation: 1

4

Welcome to Super User PaulG. While you have tried to answer OP's question but it lacks supporting facts & it may lead to deletion. Please refer to how & why some answers are deleted & how to write a good answer

– pun – 2015-08-03T21:08:21.053