I'm trying to start a java process passing several parameters to it using a bat file. But the problem is that the cmd only jumps and doesn't show anything when using:
start cmd/C
so making it
start cmd/K
gives a pop-up cmd where this error is shown
'C:\New' is not recognized as an internal or external command, operable program or batch file.
For testing purpose for reproducing the problem you can start a java process by the example below.
I have searched for a solution, but the only thing that is similar to the problem was to use set and after that to work with the parameter. set "var=content"
The echo correctly prints the folder with many spaces like: "C:\New Folder and Spaces"
The code is below:
SET "currDir=%~dp0"
echo %currDir%
start cmd /K "%currDir%"..\jvm\jre\bin\java.exe -version
How can I pass the ~dp0 value even it has spaces in it without getting the above mentioned error? What if I should use it several times in a start command like:
start cmd /K "%currDir%"..\jvm\jre\bin\java.exe -version -Djava.awt.headless=true %JAVA_OPTIONS% -jar "%~dp0MyJar.jar" -home "%~dp0.." %*
%~dp0, there is only%cd%which points to the current folder, the current working directory else called. Please clarify that for further help. - double-beep"%~dp0..\jvm\jre\bin\java.exe"! 2.startmay interpret the first quoted string as a window title, so explicitly provide such, likestart "" cmd ..., to avoid unexpected results. 3. There is no need for an interim variable%currDir%, you can use%~dp0immediately. 4. Why so you usecmd /Corcmd /Kto runjava.exe? - aschipfl