Path: utzoo!attcan!uunet!munnari.oz.au!cluster!atom!rjc From: rjc@atom.OZ (Robert Cawley) Newsgroups: comp.sys.ibm.pc Subject: Re: How can I set a PATH longer than 128 bytes? Message-ID: <1486@atom.OZ> Date: 9 Mar 90 13:35:16 GMT References: <5762@ncrcae.Columbia.NCR.COM> <31300010@inmet> <25f1ea76.25da@polyslo.CalPoly.EDU> Reply-To: rjc@atom.oz.au (Robert Cawley) Organization: Australian Nuclear Science & Technology Organisation Lines: 227 In article <25f1ea76.25da@polyslo.CalPoly.EDU> jdudeck@polyslo.CalPoly.EDU (John R. Dudeck) writes: > >In article <31300010@inmet> gjs@inmet.inmet.com writes: >>One method is to use SUBST to assign some of the directories in your >>path to "virtual drives," then include the drives in your path. For >>example: >> subst E: C:\utility\word >> subst F: C:\utility\database >> subst G: C:\utility\sprdsht >> subst H: C:\utility\comm >> >> path C:\bin;E:;F:;G:;H: I missed the start of all this, but here is a program I wrote some years ago to enable me to have a path of any size (up to the size reserved in the environment by SHELL = command.com /p /e=xxx in config.sys, where xxx is the environment size. The program checks for either COMSPEC=, or PATH= as the first entry in the master environment table. This could probably be deleted, but as I only use this in my AUTOEXEC.BAT I have not bothered to do so. Usage is: in autoexec.bat PATH=c:\;c:\bin PATHEX c:\usr\bin;c:\ms\c5 PATHEX d:\zortech\bin each PATHEX line adds the listed directories to the path. I have used this little program for over 5 years without problems. It has been tested with MSDOS 3.3 and 3.2, PCDOS 4.0, 3.3, 3.2, 3.1, 2.1 and 2.0 and seems to have no problems with these. This is compiled with Microsoft C. #include #include #define PARA 0x10000l char tststr[] = "COMSPEC="; char tststr2[] = "PATH="; int dos33 = 0; int mycmp(a, b, len) char huge *a; char *b; int len; { int i; for (i = 0; i < len; i++) if ( *a++ != *b++ ) return(1); return(0); } char huge *findmast(el) int *el; { unsigned char huge *p = (unsigned char huge *) 0l; unsigned char huge *q; unsigned int owner = 0; unsigned int priown = 0; int len; int i; int first = 0; while (1) { while (*p != 'M') (long int) p += PARA; (long int) q = (long int) p + PARA; if ( (owner = *((unsigned int huge *)(p+1))) != FP_SEG(q) ) { if ( (priown && (owner == priown) && ( ( ( (len = ( *((int huge *)(p+3)) ) * 16) > strlen(tststr) ) && !mycmp(q, tststr, strlen(tststr)) ) || ( (len > strlen(tststr2)) && !mycmp(q, tststr2, strlen(tststr2)))) ) ) { *el = len; return(q); } else p = q; } else { if ( (*((unsigned int huge *)(p + 0x2c + 0x10)) == 0) ) { priown = FP_SEG(q); p = q; } else if (dos33) { char huge *p33; FP_SEG(p33) = *((unsigned int huge *)(p + 0x2c +0x10)); FP_OFF(p33) = 0; q = p33; (long int) p33 -= PARA; len = ( *((int huge *)(p33+3)) ) * 16; if ( !(!mycmp(q, tststr, strlen(tststr)) || !mycmp(q, tststr2, strlen(tststr2)) ) ) return( (char huge *) 0l); *el = len; return(q); } else return( (char huge *) 0l ); } } } addpath(ep, esv, len, path) char huge *ep; char *esv; int len; char *path; { int l; char huge *eps; char huge *oldep; char *oldesv; oldep = ep; oldesv = esv; l = 0; while (*ep) { eps = ep; while (*ep) { if (l+3 > len) return(1); *esv++ = *ep++; l++; } if (!mycmp(eps, "PATH=", 5)) { if ( *path && ((esv[-1] == ';') ? 0 : ((esv[-1] == '=') ? 0 : 1)) ) { *esv++ = ';'; l++; } while (*path) { if (l+3 > len) return(1); *esv++ = toupper(*path++); l++; } } *esv++ = '\0'; ep++; } *esv++ = '\0'; ep = oldep; esv = oldesv; while (*esv) { while (*esv) *ep++ = *esv++; *ep++ = '\0'; esv++; } *ep++ = '\0'; return(0); } main(argc, argv) int argc; char *argv[]; { char huge *ep; int len; char *esv; union REGS dosregs; if (argc != 2) { printf("Usage: pathex pathstring\n"); exit(0); } dosregs.h.ah = 0x30; /* to get dos version */ intdos(&dosregs, &dosregs); switch (dosregs.h.al) { case 2: break; case 3: if (dosregs.h.ah == 30) dos33 = 1; break; case 4: /* I don't know if this will work */ dos33 = 1; break; default: printf("Dos version %d.%d not supported\n", dosregs.h.al, dosregs.h.ah); exit(0); } if ( (long int) (ep = findmast(&len)) ) { esv = malloc(len); if (addpath(ep, esv, len, argv[1])) printf("Failed to update Master Environment table (insufficient space)\n"); } else printf("Cannot locate Master Environment table\n"); } Robert Cawley rjc@atom.oz.au ANSTO