benf.org :  other :  shrinkpath

A simple path shrinker

Windows has a pretty restrictive maximum path environment variable length. Depending on the version of windows you're using (and the assumptions of the programs you're using!), it can be 1k, 2k, or even 255 bytes(!). (eg http://support.microsoft.com/default.aspx?scid=kb;en-us;832978). Either way, it can often become way too short, especially given many programs just append what they want upon installation, without even checking it's already there. (Especially in the corporate environment where people roll their own installers).

Shrinkpath is a very simple utility which converts path entries to 8.3 format (to save size), removes duplicates, removes invalid entries, and uses junctions if you've got em.

(only the final path is written to stdout, so redirect if you want to capture it.)

Using junctions

A nice way to shrink paths is to use junctions - if you have a junction you want shrinkpath to use, specify "-j junc" (as many as you want). Eg here I've junctioned c:\pf -> "c:\program files", and c:\ws -> "c:\windows\system32"

(Junction is a sysinterals tool which creates windows reparse points for you, get it here)

by adding "-j c:\pf -j c:\ws" I tell shrinkpath to consider using these two junctions.

Much better!

Download Shrinkpath:
Last updated 2009