bencollver

10.03.2026, 02:29 |
CD environment variable (Users) |
Windows has a CD environment variable for the current working directory.
https://ss64.com/nt/syntax-variables.html
I came up with a couple of ways to set this variable on DOS.
Below is one that uses DEBUG.COM to edit SETCD.BAT
C:\>type mksetcd.bat
echo SET CD=>setcd.bat
cd>>setcd.bat
echo F 100 L 200 20 >debug.scr
echo N setcd.bat >>debug.scr
echo L 100 >>debug.scr
echo M 109 L 200 107 >>debug.scr
echo W >>debug.scr
echo Q >>debug.scr
debug <debug.scr
I could use it like so:
C:\TEMP>\mksetcd.bat
C:\TEMP>setcd.bat
C:\TEMP>echo %CD%
C:\TEMP
Do you know of a better way? |
roytam
10.03.2026, 08:03
@ bencollver
|
CD environment variable |
> Windows has a CD environment variable for the current working directory.
>
> https://ss64.com/nt/syntax-variables.html
>
> I came up with a couple of ways to set this variable on DOS.
>
> Do you know of a better way?
what about NSET? |
Rugxulo

Usono, 10.03.2026, 08:21
@ bencollver
|
CD environment variable |
> Windows has a CD environment variable for the current working directory.
>
> Do you know of a better way?
FreeDOS' FreeCOM (and also 4DOS, I think) have "%_CWD%" for this purpose.
if "%CD%"=="" if not "%_CWD%"=="" set CD=%_CWD%
if "%CD%"=="" goto error
|
bencollver

10.03.2026, 14:51
@ Rugxulo
|
CD environment variable |
> FreeDOS' FreeCOM (and also 4DOS, I think) have "%_CWD%" for this purpose.
>
>
> if "%CD%"=="" if not "%_CWD%"=="" set CD=%_CWD%
> if "%CD%"=="" goto error
>
Thanks for sharing this knowledge, rugxulo! |
bencollver

10.03.2026, 14:53 (edited by bencollver, 10.03.2026, 15:09)
@ roytam
|
CD environment variable |
> what about NSET?
Thanks, i didn't know about NSET. I see the author's site has other goodies:
https://www.horstmuc.de/main.htm
p.s.
NSET 2.1
https://www.horstmuc.de/horst.htm
NSET 1.2
http://annex.retroarchive.org/cdrom/psl-jan95/DOS/UT_DSKFI/HORST_1/ |