Microsoft KB Archive/72171

From BetaArchive Wiki
Knowledge Base


Workarounds for 128 Character PATH Limitation

PSS ID Number: 72171

Article Last Modified on 5/12/2003



The information in this article applies to:

  • Microsoft Windows NT Server 4.0 Terminal Server Edition SP4
  • Microsoft Windows NT Server 4.0 Terminal Server Edition SP5
  • Microsoft Windows NT Server 4.0 Terminal Server Edition SP6
  • Microsoft Windows 2000 Server SP1
  • Microsoft Windows 2000 Advanced Server SP1
  • Microsoft Windows 2000 Professional SP1
  • Microsoft MS-DOS operating system 3.1
  • Microsoft MS-DOS operating system 3.2
  • Microsoft MS-DOS operating system 3.21
  • Microsoft MS-DOS operating system 3.3
  • Microsoft MS-DOS operating system 3.3a
  • Microsoft MS-DOS operating system 4.0
  • Microsoft MS-DOS operating system 4.01
  • Microsoft MS-DOS operating system 5.0
  • Microsoft MS-DOS operating system 5.0a
  • Microsoft MS-DOS operating system 6.0
  • Microsoft MS-DOS operating system 6.2
  • Microsoft MS-DOS operating system 6.21
  • Microsoft MS-DOS operating system 6.22
  • Microsoft Windows NT Server 4.0
  • Microsoft Windows NT Server 4.0 SP1
  • Microsoft Windows NT Server 4.0 SP2
  • Microsoft Windows NT Server 4.0 SP3
  • Microsoft Windows NT Server 4.0 SP4
  • Microsoft Windows NT Server 4.0 SP5
  • Microsoft Windows NT Server 4.0 SP6a
  • Microsoft Windows NT Server, Enterprise Edition 4.0
  • Microsoft Windows NT Server, Enterprise Edition 4.0 SP4
  • Microsoft Windows NT Server, Enterprise Edition 4.0 SP5
  • Microsoft Windows NT Server, Enterprise Edition 4.0 SP6a
  • Microsoft Windows NT Workstation 4.0
  • Microsoft Windows NT Workstation 4.0 SP1
  • Microsoft Windows NT Workstation 4.0 SP2
  • Microsoft Windows NT Workstation 4.0 SP3
  • Microsoft Windows NT Workstation 4.0 SP4
  • Microsoft Windows NT Workstation 4.0 SP5
  • Microsoft Windows NT Workstation 4.0 SP6a



This article was previously published under Q72171

SUMMARY

All MS-DOS environment variables are limited by the COMMAND.COM input buffer length of 128 characters, including the PATH. The figure 128 includes an end-of-variable character, the variable name, and the = (equal) sign. Therefore, PATH actually has only 122 characters to hold the directories you want COMMAND.COM to search. This limit cannot be expanded.

The following are some techniques to get the most use out of those 122 characters:

  • Use "C:" instead of "C:\".
  • Eliminate unneeded directories from your PATH.
  • Use short directory names.
  • Create batch files that modify the PATH as necessary.
  • Create batch files that execute programs.
  • Eliminate drive letters in the PATH.
  • Reduce the number of directories.
  • Substitute drive letters for directories with SUBST.
  • Use third party terminate-and-stay-resident "PATH extenders."
  • Replace COMMAND.COM with another command interpreter.


MORE INFORMATION

  1. If you want MS-DOS to search the root directory of a drive, omit the \ (backslash) by typing the following command:

    path c:

    This causes MS-DOS to search C:\ regardless of the current directory of C.

    NOTE: This does not mean removing the "\" from all directories in the PATH command, only from the single reference to the root directory.
  2. Eliminate unneeded directories from your PATH. Many applications automatically add their directories to the PATH, whether you want them there or not. In addition, when a PATH is very long, the search time to find items becomes quite lengthy because MS-DOS must search all the directories in the PATH.

    You may need to change directories to run applications not in the PATH.
  3. Use short directory names. This may require renaming directories, which can be done with the MS-DOS Shell and many third-party utility packages.

    Short directory names tend to be more cryptic and difficult to remember. Also, some applications (notably menu programs) save directory information for future use and may even require reinstallation to be able to use another directory.

    NOTE: Do NOT rename a directory when any program is using any files in that directory. For this reason, it is best to exit from all applications and/or multitasking and task switching software, such as Windows, before renaming directories.
  4. Set up a series of batch files that set up the path depending on your current needs. One way to do this is to have a BASEPATH.BAT file, which sets a minimal or basic path, and then to have other batch files that modify this basic path. Another way is to have a batch file save the current PATH, set a new one, and then restore the previous PATH. For more information, query on the following words:

    saving and old and path

    However, you must invest time and effort in making and maintaining the batch file system.
  5. Batch files can also be used to change to the appropriate subdirectory, execute the program desired, and change back. For more information, see the descriptions of creating a menu system with batch files as described in "Supercharging MS-DOS" by Van Wolverton, and in the Microsoft Quick Reference book "MS-DOS Batch Files" by Kris Jamsa. Both of these are published by Microsoft Press.

    However, you must invest time and effort in making and maintaining the batch file system.
  6. If you primarily use only one logical drive for most of your activity, do not add the drive specification for each path entry. For example, if you are primarily using drive C, and your path used to be the following

           set path=c:\bin;c:\dos;c:\win;c:\util

    you could shorten it to the following:

           set path=\bin;\dos;\win;\util

    NOTES:

    Removing drive letters from your path creates problems with shared applications in Windows. (Some shared applications do not run.)

    This method will only work while your active drive is drive C. If you move to drive A, MS-DOS will look for the path entry on the A drive. This can cause the MS-DOS search to work incorrectly.

    For example, the PATH was edited to include \WIN, instead of C:\WIN, and the command WIN was typed at the C prompt:

    C:\>win

    MS-DOS would find and run C:\WIN\WIN.COM. But this would not be true if the command was typed at the A prompt:

    A:\>win

    This would result in a "Bad command or file name error" because MS-DOS would be searching for A:\WIN\WIN.COM.

  7. Group path entries together, moving executable files from more than one path entry into a single directory. For example, if you use several utility packages, you might want to group them into C:\UTIL instead of C:\NORTON, C:\PCTOOLS, and C:\SK.

    NOTE: This may make it harder to organize your drive.
  8. The SUBST command can be used to substitute a drive letter for a directory. (If drive letters past E are used, it may be necessary to add or modify the LASTDRIVE= statement in CONFIG.SYS.) The following commands demonstrate how this is used:

           C:\dos\subst i: c:\util
           C:\dos\subst j: c:\c600a
           path c:\dos;i:;i:\bats;i:\nu;j:\binb;j:\binr;j:\binp;
                            

    These lines could be in the AUTOEXEC.BAT file, or in a SETPATH.BAT file, which could then be called as needed.

    Because SUBST disguises the real directory structure, it can cause problems for some applications and some DOS utilities. For example, you cannot remove a SUBSTituted directory or FORMAT a SUBSTituted drive.

    NOTE: SUBST should not be active when Microsoft Windows is being installed. To display any SUBSTituted directories, type SUBST at the prompt with no parameters:

           C:\>subst
           I: => C:\util
           J: => C:\c600a
                            

    To deactivate the SUBST command for these directories, type the following:

    C:\>SUBST I: /D
    C:\>SUBST J: /D

    For more information on SUBST and Windows, query on the following words:

    SUBST and join and Windows and problems

  9. There are third party "PATH extenders" that fool COMMAND.COM into using a longer PATH. Some are shareware and/or public domain.

    Drawback: These programs may be dependent on particular MS-DOS versions and may interfere with applications that expect a maximum PATH of 128 characters.
  10. Finally, as the 128-character limit is a limitation of the command interpreter, COMMAND.COM, the limit can be bypassed entirely by not using COMMAND.COM. MS-DOS version 2.00 introduced support for using an alternate command interpreter (or "shell") with the CONFIG.SYS SHELL= command.

    A third-party command interpreter called NDOS is supplied with Norton Utilities version 6, along with a NDOS manual. NDOS is compatible with MS_DOS 5.0. The path limit for NDOS is 244 characters. For more information, contact:

    Symantec, Peter Norton Group
    10201 Torre Avenue
    Cupertino, Ca. 95014-2132
    (408) 253-9600

    A third-party choice is the product 4DOS, by J.P. Software, which has a 256 character environment variable limit. For more information, contact:

    J.P. Software
    P.O. 1470
    East Arlington, MA 02174
    (617) 646-3975

    Drawback: 4DOS and other command interpreters may not work with all applications or all MS-DOS versions.

All MS-DOS environment variables are limited by the COMMAND.COM input buffer length of 128 characters. The PATH statement and other environment variables cannot exceed 127 characters, including spaces. The total length of the statement is 128 bytes; however, the 128th is reserved for an "End-Of-String" NULL byte.

The products included here are manufactured by vendors independent of Microsoft; we make no warranty, implied or otherwise, regarding these products' performance or reliability.


Additional query words: 3.20 3.21 3.30 3.30a 4.00 4.01 4.01a 5.00

Keywords: KB72171
Technology: kbMSDOS310 kbMSDOS320 kbMSDOS321 kbMSDOS330 kbMSDOS330a kbMSDOS400 kbMSDOS401 kbMSDOS500 kbMSDOS500a kbMSDOS600 kbMSDOS620 kbMSDOS621 kbMSDOS622 kbMSDOSSearch kbNTTermServ400 kbNTTermServ400sp4 kbNTTermServ400sp5 kbNTTermServ400sp6 kbNTTermServSearch kbwin2000AdvServ kbwin2000AdvServSearch kbWin2000AdvServSP1 kbwin2000Pro kbwin2000ProSearch kbWin2000ProSP1 kbwin2000Search kbwin2000Serv kbwin2000ServSearch kbwin2000ServSP1 kbWinAdvServSearch kbWinNT400search kbWinNTS400 kbWinNTS400search kbWinNTS400sp1 kbWinNTS400sp2 kbWinNTS400sp3 kbWinNTS400sp4 kbWinNTS400sp5 kbWinNTS400sp6 kbWinNTsearch kbWinNTSEnt400 kbWinNTSEnt400sp4 kbWinNTSEnt400sp5 kbWinNTSEnt400SP6a kbWinNTSEntSearch kbWinNTSsearch kbWinNTW400 kbWinNTW400search kbWinNTW400sp1 kbWinNTW400sp2 kbWinNTW400sp3 kbWinNTW400sp4 kbWinNTW400sp5 kbWinNTW400SP6a kbWinNTWsearch