I want to run a command in a specific directory and then return back. (There is a reason for it [validity of parameters...]).
I tried doing it in batch file for DOSBox...
@echo off
cd>cd.cd
cd %mypath%
dosomething 1 2 3
::I am not sure....
cd (type cd.cd)
%CD%
, %dI
, FOR
loop nothing works in DOSBox...
I wrote a C program but couldn't find a function that returns the current directory for TURBO C 16-bit...
Can someone please help me out with this?
%CD%
is a variable in Windows cmd so you can't use it in MS-DOS. You can work around that by storing the current directory output from the cd
command without any parameters into a variable by redirecting command output to file then read the file from disk
@set cd=
without any newlines. It can be created in DOS by pressing Ctrl+Z then Enter while running COPY CON
. Let's name it init.txtThen everytime you want to get the current directory run
cd >cd.txt
copy init.txt+cd.txt setcd.bat
setcd
%CD%
variable