Add %CD% to PATH in command.com - note that cmd.exe fix does not work

0

Goal: Issue a simple command to add the current directory to the PATH statement. Rather than type in every agonizing stroke, I would rather call a batch file, say xpath (where xpath.bat sits in an active path).
Doesn't work: path=%path%;%cd% does not work under command.com, neither in batch nor on the command line, although it works perfectly in later cmd.exe systems.
Confusing: Several other system variables or strings can be manipulated this way.

%CD% (or CD) is behaving differently.

Environment: I am using FreeDOS 1.2 under Virtualbox 5.2.22
This failure is consistent under MS-DOS 6.22 also under Vbx 5.2.22


C:\SSH>path  
PATH=C:\FDOS\BIN
C:\SSH>set newdir=C:\SSH\CONTRIB
C:\SSH>echo %newdir%
C:\SSH\CONTRIB                    // success
C:\SSH>path=%path%;%newdir%
C:\SSH>path
PATH=C:\FDOS\BIN;C:\SSH\CONTRIB   // success  

*** But

C:\SSH>path 
PATH=C:\FDOS\BIN
C:\SSH>set newdir=%cd%
C:\SSH>echo %newdir%
ECHO is on                        // unexpected
C:\SSH>path=%path%;%newdir%
C:\SSH>path
PATH=C:\FDOS\BIN;C:\SSH\CONTRIB   //unchanged

The "echo is on" as well as other failures are consistent with %cd% resolving to nothing.
So CD, like PATH, appears to be a COMMAND whose output can be captured by evaluating it as a %VARIABLE%, but this is probably only the desired appearance. Sounds like the two are fundamentally different, and CD does not work consistently under COMMAND.COM.
NOTE that there is another question floating around out there with a solution that works nicely under cmd.exe. This is not that.

user268926

Posted 2019-01-26T04:48:20.113

Reputation:

Answers

0

ratburgerian. Just try and use a small DOS utility such as PATHA.COM or any similar one. Here is its syntax :

PATHA [text or /c] [ /f /d /e /b /o ]
PATHA provides various ways to modify the current path.

PATHA : show current path.
PATHA [text] : Add directory(s) [text] to the current path.

    OPTIONS
  • `[text]` : A single directory (i.e. c:\DOS) or multiple directories separated by ;'s (i.e. c:\;c:\dos).
  • /c : use Current working directory as [text].
  • /b : add to the Beginning of the path.
  • /d : Delete from the path.
  • /e : Edit the resulting path before changing.
  • /o : Override checking if directory exist.
  • /f : replace path with path in File [text], or from \autoexec.bat if [text] not entered.
    Note: options may be combined. (i.e. PATHA /c /e).  

Copyright 1992 HGB Enterprises, All Rights Reserved. Ver 1.1

The version I use is this one :

patha .com 14112 15-04-1992 19:39 "patha.com"

This does work with my real DOSes (M$ 6.22 and Novell 7.15) PCs.

user990536

Posted 2019-01-26T04:48:20.113

Reputation: 1

Formatting completely ruined by StackExchange ! – user990536 – 2019-01-27T10:53:22.923