Jan 012018
 
Allows you to enter a path as long as you like.
File LONGPATH.ZIP from The Programmer’s Corner in
Category Utilities for DOS and Windows Machines
Allows you to enter a path as long as you like.
File Name File Size Zip Size Zip Type
LONGPATH.DOC 6821 1985 deflated
LONGPATH.EXE 12260 6829 deflated

Download File LONGPATH.ZIP Here

Contents of the LONGPATH.DOC file


The program LONGPATH may be used to add aditional directories to an existing
path and thus produce a path longer than the DOS limit of about 125
characters. It may also be used to delete or replace an existing path.


Call: C>LONGPATH [additional path info] ( to add to existing path )
C>LONGPATH path=[new path] ( to replace existing path )
C>LONGPATH path= ( to delete existing path )


Return code: 0 successful (path added or deleted)
1 no parms or more than 1 parm on command line (path not changed)
2 not enough environment space (path not changed)


Sample use:

C>path
PATH=D:\;C:\

C>longpath ;c:\dos;c:\util

LONGPATH successful. New PATH is:
PATH=D:\;C:\;c:\dos;c:\util

C>longpath path=

LONGPATH successful. PATH deleted.

C>longpath path=d:\;c:\

LONGPATH successful. New PATH is:
PATH=d:\;c:\

C>_


Notes: The number of characters that can be added to the path at one time is
limited by the length of the command line. Therefore, for a really
really long path it is necessary to run the LONGPATH program several
times.

The use of %PATH% to access the path environment variable from within
a batch file will not work if the path is longer than about 125
characters.

To delete a path longer than 125 characters use the 'longpath path='
option. The results of using the DOS 'set path=' command is
unpredictable.

To increase the size of the environment include the SHELL command
in your config.sys file.


For the technically inclined:

The following is the source code for the LONGPATH program

/* Program to append additional information to the PATH environment variable */
/* */
/* This program may be used to add additional sub directories to the path */
/* and thus produce a path longer than the DOS limit of about 125 characters */
/* */
/* Call: C>LONGPATH [additional path info] ( to add to existing path ) */
/* C>LONGPATH path=[new path] ( to replace existing path ) */
/* C>LONGPATH path= ( to delete existing path ) */
/* */
/* Return code = 0 successful - path added or deleted */
/* 1 no parms or more than 1 parm on command line */
/* 2 not enough environment space */
/* */
/* Note: This program was compiled with Borland's Turbo C compiler */
/* version 2.0 using the small memory model */

#include
#include
#include
#include

typedef enum {false, true} boolean;
typedef unsigned char byte;
typedef unsigned int word;

typedef struct /* Program Segment Prefix - PSP */
{
char pspfiller1[22]; /* filler */
word pspprior; /* segment of parent */
char pspfiller2[20]; /* more filler */
word pspenv; /* segment of environment */
} psphdr;

boolean startup(char *argp[], char **npath, char far **envpp)
{ /* setup new path and pointer */
boolean serror; /* to environment */
int i,j,k;
psphdr far *pspp; /* pointer to PSP */
word far *envsp; /* pointer to size of environment */
char *pathp; /* current PATH */

serror=false;
pathp=getenv("PATH");
k=strlen(pathp);
if (strnicmp(argp[1],"PATH=",5)==0) /* get memory for new path */
{ /* and construct new path */
i=strlen(argp[1])+1;
*npath=malloc(i);
strcpy(*npath,argp[1]);
for (j=0; j<4; j++)
(*npath)[j]=(*npath)[j] & 0xdf;
}
else
{
i=k+strlen(argp[1])+strlen("PATH=")+1;
*npath=malloc(i);
strcpy(*npath,"PATH=");
if (pathp!=NULL)
strcat(*npath,pathp);
strcat(*npath,argp[1]);
}
putenv(*npath);

pspp=MK_FP(_psp,0x0000); /* follow psp chain to top and get */
while (pspp!=MK_FP(pspp->pspprior,0x0000)) /* pointer to environment */
pspp=MK_FP(pspp->pspprior,0x0000); /* and to size of environ */
*envpp=(char far *)MK_FP(pspp->pspenv,0x0000);
envsp=MK_FP(pspp->pspenv-1,0x0003);
j=1;
for (i=0; environ[i]!=NULL; i++) /* compute total size of all */
{ /* environment variables and */
if (strcmp(environ[i],"PATH=")!=0) /* set error if not enough room */
j=j+strlen(environ[i])+1;
}
i=*envsp<<4;
if (j>i)
serror=true;
return(serror);
}

void main(int ict, char *argp[])
{
boolean delpath;
int retcode;
word i,j,k;
char *npath; /* pointer to new path */
char far *envpp; /* pointer to environment */

delpath=false;
if (ict!=2) /* check for proper number of args */
{
puts("\nPath to be added to current path must be entered on command line.");
puts(" i.e. C>LONGPATH ;C:\\ADDED\\PATH");
retcode=1;
}
else
{
if (startup(argp,&npath,&envpp)==true) /* get new path and env ptr */
{
puts("\nNot enough environment space. PATH not changed.");
retcode=2;
}
else
{
j=0;
for (i=0; environ[i]!=NULL; i++) /* rebuild entire environment */
{
if (strcmp(environ[i],"PATH=")!=0)
{
k=strlen(environ[i])+1;
movedata(_DS,(unsigned)environ[i],FP_SEG(envpp),FP_OFF(envpp),k);
j=j+k;
envpp=MK_FP(FP_SEG(envpp),j);
}
else
{
delpath=true;
}
}
*(char far *)envpp='\0'; /* set end of environment */
retcode=0;
}
}
if (retcode==0)
{
if (delpath==false)
{
puts("\nLONGPATH successful. New PATH is:");
printf("%s\n",npath);
}
else
{
puts("\nLONGPATH successful. PATH deleted.");
}
}
exit(retcode);
}


 January 1, 2018  Add comments

Leave a Reply