Answer the question
In order to leave comments, you need to log in
How to specify the path from which it is launched inside the batnik?
There is a batch file, and next to it in the same folder is a java program, you need the batch file to run this program and show the console window with the program already open, but for this, in theory, you need to specify the full path to the program, no? Before that, I didn’t communicate with batch files, but then it became necessary to transfer the program to a person very far from the PC, and I don’t want to explain the work in the console on my fingers.
Answer the question
In order to leave comments, you need to log in
but for this, in theory, you need to specify the full path to the program, no?No. If to a file in the same folder (or in folders listed in the PATH variable), then the path is not needed.
The most reliable option is the value of the environment variable: %~dp0.
The %0 variable contains the path and name of the executable file (possibly relative).
The ~dp expression forms the full path (drive and subdirectory) excluding the file name.
StackOverflow discussion What does %~dp0 mean, and how does it work?
@echo off
setlocal
echo %%0 = %0
echo %%~dp0 = %~dp0
endlocal
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question