Suppose in a batch file:
cd C:\Program Files\path\test\ start someprg.exe
How after executing these commands, go back to the directory to the batch file, wherever it is?
In fact, both proposed solutions return the memorized working directory , which does not correspond to the literal condition of the problem:
go back to the directory to the batch file, wherever it is
You can change the directory to the one in which the batch file is located as follows:
CD /DA:\SOME\ REM делаем что-либо с относительными путями CD /D "%~dp0"
CALL /?
. I also often look at the third-party site ss64.com. In principle, I consider the topic of information and literature necessary for administrative scripting in NT worthy of a separate issue. - karmadro4See help set in cmd
set curdir=%cd% cd c:\ushare dir cd %curdir%
Something like that.
Sometimes it can be useful to use the commands PUSHD (move to a folder and remember the old one) and POPD (return to a memorized folder)
PUSHD папка REM Что-то полезное делаем POPD
It is best to use variables in this case:
set up=%cd% Rem здесь тело батника cd %up%
Source: https://ru.stackoverflow.com/questions/80666/
All Articles