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

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.


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.


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


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.)


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.


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.