[comp.sys.ibm.pc.programmer] Setting the path variable in autoexec.bat

stever@Octopus.COM (Steve Resnick ) (06/29/90)

In article <1102@valinor.ACA.MCC.COM> hang@valinor.ACA.MCC.COM (Hang Ho Ng) writes:
>I have a number of paths that I want to include in the PATH variable in
>autoexec.bat file. Could someone tell me how to do it? I've tried putting 
>all the paths in one extra long line but somehow the trailing paths are
>always truncated. I think there must be a line continuation character that
>I can use as in setting the PATH variable in Unix.
>
>

(Asbestos Suit: ON)  8-)

This was covered a couple of months ago. The DOS limitation on command
strings (PATH=<foo> for instance) is 128 bytes. If your path is longer than 
that you will either need some program to allow you to enter a longer string.
(Of which I don't know of any) or you will need to limit your path to a smaller
size and use batch files to assist in navigation.
 
 Hope this helps....
 Steve


-- 
--------------------------------------------------------------------------------
Steve Resnick -<stever@octopus.COM apple!octopus!stever sun!vsi1!octopus!stever>
408/241-1533 Process Scientific, Inc.
"0x2B|~0x2B THAT is the question!"

djb@bbt.UUCP (beauvais) (07/03/90)

In article <1990Jun28.211556.10833@Octopus.COM> stever@octopus.UUCP (Steve Resnick ) writes:
>In article <1102@valinor.ACA.MCC.COM> hang@valinor.ACA.MCC.COM (Hang Ho Ng) writes:
>>I have a number of paths that I want to include in the PATH variable in
>>autoexec.bat file. Could someone tell me how to do it?
>
>This was covered a couple of months ago. The DOS limitation on command
>strings (PATH=<foo> for instance) is 128 bytes. If your path is longer than 
>that you will either need some program to allow you to enter a longer string.
>(Of which I don't know of any) or you will need to limit your path to a smaller
>size and use batch files to assist in navigation.

True, a DOS command line IS limited to 128 characters.  So, use more than
one command line!  Try something like this...

path=c:\dos;c:\;d:\utils
path=%path%;d:\wp;d:\edit

The %path% means "whatever the current path is."  The second line appends
the new stuff to the value of %path%.  This works fine in DOS 3.3 - I use
it all the time for paths longer than 132 characters.



-- 
	Dan Beauvais                    ...!mcnc!rti!bbt!djb
	BroadBand Technologies, Inc.  +1(919)-544-6850 x 295
	Box 13737     Research Triangle Park, NC  27709-3737

stever@Octopus.COM (Steve Resnick ) (07/04/90)

In article <857@bbt.UUCP> djb@bbt.UUCP (beauvais) writes:
>In article <1990Jun28.211556.10833@Octopus.COM> stever@octopus.UUCP (Steve Resnick ) writes:
>>In article <1102@valinor.ACA.MCC.COM> hang@valinor.ACA.MCC.COM (Hang Ho Ng) writes:
>>>I have a number of paths that I want to include in the PATH variable in
>>>autoexec.bat file. Could someone tell me how to do it?
>>
>>This was covered a couple of months ago. The DOS limitation on command
>>strings (PATH=<foo> for instance) is 128 bytes. If your path is longer than 
>>that you will either need some program to allow you to enter a longer string.
>>(Of which I don't know of any) or you will need to limit your path to a smaller
>>size and use batch files to assist in navigation.
>
>True, a DOS command line IS limited to 128 characters.  So, use more than
>one command line!  Try something like this...
>
>path=c:\dos;c:\;d:\utils
>path=%path%;d:\wp;d:\edit
>
>The %path% means "whatever the current path is."  The second line appends
>the new stuff to the value of %path%.  This works fine in DOS 3.3 - I use
>it all the time for paths longer than 132 characters.
>

I don't know what you are running, but my version of DOS (Generic MS DOS 3.30)
will not do this. There is a good reason, it has to do with the way that
COMMAND.COM expands environment variables. When command encounters a word
enclosed in percent symbols it substitutes the value of the environment variable
(or "" is it doesn't exist). Once all expansions are done the command gets 
executed (I know I missed a few items in there). The point is that the command
string is >128 bytes before it gets executed. I don't know what version of DOS
you are running, but the stuff from Microsoft will not do a path (or any other
command) greater than 128 bytes.
 
  
  Cheers!
  Steve


-- 
--------------------------------------------------------------------------------
Steve Resnick -<stever@octopus.COM apple!octopus!stever sun!vsi1!octopus!stever>
408/241-1533 Process Scientific, Inc.
"0x2B|~0x2B THAT is the question!"

bmp@hp-ptp.HP.COM (Brian Perkin) (07/06/90)

Sounds like time to add this to frequently asked questions...

Brian

craig@aspect.UUCP (Craig Schreiner) (07/06/90)

In article <857@bbt.UUCP>, djb@bbt.UUCP (beauvais) writes:
> In article <1990Jun28.211556.10833@Octopus.COM> stever@octopus.UUCP (Steve Resnick ) writes:
1 >In article <1102@valinor.ACA.MCC.COM> hang@valinor.ACA.MCC.COM (Hang Ho Ng) writes:
1 >>I have a number of paths that I want to include in the PATH variable in
1 >>autoexec.bat file. Could someone tell me how to do it?
1 >
1 >This was covered a couple of months ago. The DOS limitation on command
1 >strings (PATH=<foo> for instance) is 128 bytes. If your path is longer than 
1 >that you will either need some program to allow you to enter a longer string.
1 >(Of which I don't know of any) or you will need to limit your path to a smaller
1 >size and use batch files to assist in navigation.
> > 
2 > True, a DOS command line IS limited to 128 characters.  So, use more than
2 > one command line!  Try something like this...
2 > 
2 > path=c:\dos;c:\;d:\utils
2 > path=%path%;d:\wp;d:\edit
2 > 
2 > The %path% means "whatever the current path is."  The second line appends
2 > the new stuff to the value of %path%.  This works fine in DOS 3.3 - I use
2 > it all the time for paths longer than 132 characters.

This won't work!  Using the %PATH% expands the contents of the PATH
environment before executing the command line.  Therefore if your
PATH is say some 100 bytes long and you attempt to add another 30 bytes
and then counting for the 5 bytes for the PATH= command, your system
will either crash (depending on hardware versions, like some I've used)
or just continue truncating the path to the 128 bytes.  Unfortunately
there is no real good solution to solving this problem except by
batching or stuffing one directory full of all your executables to
get around this symptom.  Too bad newer version of DOS weren't made
to allow longer command lines!
-----
Craig

cak@vpnet.chi.il.us (Cindi Knox) (07/06/90)

The system performance comment is all too true. As I am in the repair
biz, I get a lot of strange stuff. Two common problems:

     "If I type a wrong name for a program, the computer `locks up' for
      a while' "

SOLUTION: Shorten the path. (The system takes a look EVERYWHERE for the
          program before giving up) Also causes various errors when a 
          program is found in another directory but needs files found in
          said directory. PATH doesn't help that. 
ALSO TRY: PATH C:\BIN;C:\USR\BIN;C:\USR\BAT;..
          the .. will get programs out of the parent directory. Useful
          when you divide up files (BASIC\GAMES, BASIC\COMM, BASIC\CAD)

     "My hard disk needs to be replaced. It's slowing down"

CAUSE:    User has 4 subdirectories on a 10MB hard disk. Root has DOS,
          transient programs from DOS, CONFIG.SYS and AUTOEXEC.BAT. 
          Three subdirs have very little, the fourth has EVERYTHING
          THIS PERSON EVER USED, WROTE, PRINTED, or GAVE UP ON! The
          disk is near capacity and the directory (itself a file) is
          split up on the disk due to fragmentation. A full directory
          listing takes FIVE MINUTES! Another symptom was "FILE CREATION
          ERROR" due to the fact there was no directory space. 

SOLUTION: I hate to say it, but Apple has the right idea when they call
          directories ``folders.'' USE A DIRECTORY LIKE A FILE FOLDER!
          You wouldn't stuff everything in one folder, would you?


             I doubt any of these opinions are those of my employer.
                   I don't agree with ANYTHING they say.

Cindi Knox          | You've got a lot of living to do without life.
                    | 
cak@vpnet.chi.il.us | ``Little Miss S.'' by  Edie Brickell and New Bohemians.

ericm@ims.UUCP (Eric Martinson) (07/07/90)

I have a couple of ways to deal with this problem.  On my system I 
have drive letters C:, D:, E:, F:, and G: which are all hard disk
partitions.  On C: I have a directory named C:\APPS.  In this 
directory I have one subdirectory for each of my applications I
use.  The directories are:

C:\APPS\SP			(Borland Sprint)
C:\APPS\FP			(First Publisher)
C:\APPS\PCTOOLS		(PC Tools Deluxe V6)
C:\APPS\QP			(Borland Quattro Professional)
..
..

The directory names themselves are short (i.e. SP for Sprint
rather than SPRINT.)  The next thing I do is make sure the
line:

LASTDRIVE=Z

is in the CONFIG.SYS file.  Then I use the SUBST command in
by autoexec command to set up a path that gets me one dir
away from all of these applications:

SUBST P: C:\APPS

This allows me to place P:SP;P:FP;P:PCTOOLS;P:QP into the
path and have direct command access to all of these 
applications.

There are ways to increase the size of the PATH variable
using programs that know how to edit the parent environment
but I haven't seen one that's really complete.  I wrote a
simple one that provides no useful interface.  I works.  I
chose the above because several applications croak if the
path is longer than 128 bytes (127 characters plus NULL.)

It's really quite disgusting that DOS has this signed 
byte limit on the length of a command line string. 

cjp@beartrk.beartrack.com (CJ Pilzer) (07/07/90)

The limit on the length of the PATH is in the fact that Command.com will
not pass a line longer than 127 characters.  Since 5 characters are used
by the word "path=", the command.com will truncate the actual path to 122
characters.  The reason the %path% ideas don't work is because the varible
expansion occurs in command.com before the line is send out and is therefore
truncated.

There is no reasonble limit to length of the path if you can get it into the
environment.  There are programs which will do this such as ADDPATH and LONGEST.
They are in the IBMSYS library of Compuserve.  I don't know where to get them
on this network.  The best solution is the Command.com replacement 4DOS.  It
has a command line of 255 characters and a command ESET which allows you to
directly edit the path.  4DOS is so great that this is the least of the
benefits you can get from using it. 

-- cj

kdq@demott.COM (Kevin D. Quitt) (07/08/90)

In article <8240002@hp-ptp.HP.COM> bmp@hp-ptp.HP.COM (Brian Perkin) writes:
>Sounds like time to add this to frequently asked questions...
>
>Brian


    It's already in there!  Maybe what we need is a one month expiration
on the posting, so that new people get it first.


-- 
 _
Kevin D. Quitt         demott!kdq   kdq@demott.com
DeMott Electronics Co. 14707 Keswick St.   Van Nuys, CA 91405-1266
VOICE (818) 988-4975   FAX (818) 997-1190  MODEM (818) 997-4496 PEP last

                96.37% of all statistics are made up.