Windows PATH too long

I recently discovered that Windows does something funny when the path variable gets too big. (Here I mean that PATH variable + the user PATH variable).

The funny thing is that it seems to permute the string somehow because after adding/removing an extra string Windows and all new cmd’s would loose all knowledge of the PATH variable until next reboot. Then after reboot it comes back to life again.

An interesting observation was to see how windows uses the path variable internally, and that is for opening the dialogue where you change the PATH variable 🙁

systempropertiesadvance

systempropertiesadvance zoom

 

I found an approach that shortened the path enough for me here

Basically I converted the path to the short 8dot3 format with this script:

@echo off

SET MyPath=%PATH%
echo %MyPath%
echo --

setlocal EnableDelayedExpansion

SET TempPath="%MyPath:;=";"%"
SET var=
FOR %%a IN (%TempPath%) DO (
    IF exist %%~sa (
        SET "var=!var!;%%~sa
    ) ELSE (
        echo %%a does not exist
    )
)

echo --
echo !var:~1!

 

Tagged with: ,
2 comments on “Windows PATH too long
  1. Riona says:

    You can try Long Path Tool, it helped me a lot.

  2. Anand Shaw says:

    Use Long Path tool to solve this problem easily…

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.