Headsup on command line for shortcuts in Windows XP

bart on 2010-03-02T14:26:35

For Strawberry Perl, and Padre, I use a custom entry in the Start Menu, which technically is a shortcut (*.LNK file). For example, for Padre the command line in the shortcut file was:

C:\WINDOWS\system32\cmd.exe /c PATH=c:\strawberry\perl\bin;c:\strawberry\c\bin;%PATH% && padre

Likewise, the command line for my Strawberry shell was:

C:\WINDOWS\system32\cmd.exe /k PATH=c:\strawberry\perl\bin;c:\strawberry\c\bin;%PATH%

Overnight, these both stopped working.

After a bit of puzzling, I figured out that a new program had been installed by Windows Update, and this had added a new directory to PATH. As a result, after the environment variable was substituted with its real value, the length of the expanded command line was now longer than 256 bytes, and now PATH got truncated.

Remember, folks:

The length of the command line for a shortcut, after expansion, should never be longer than 256 bytes.

If you put the code for modification of PATH in a *.BAT file, no such restriction applies.

So now, my shortcut to start the command shell is:

C:\WINDOWS\system32\cmd.exe /k c:\strawberry\strawberry_path.bat

where c:\strawberry\strawberry_path.bat contains the lines

@echo off
PATH=C:\strawberry\c\bin;C:\strawberry\perl\bin;%PATH%

which makes it easier for me to add more Perl based tools that depend on these entries in PATH: I now have a central location for the definition, if I ever need to add or modify a directory.