shathor/JShellStandalone

Don't use %cd% in batch file

shartte opened this issue · 1 comments

Using "%cd%"\bin\jshell in the batch file means it cannot be called using an absolute path from another directory:

D:\>jshell\jshell.cmd

D:\>"D:\"\bin\jshell -v --start DEFAULT --start PRINTING
The system cannot find the path specified.

What you actually want is:

%~dp0bin\jshell -v --start DEFAULT --start PRINTING

This will insert the full path of the directory that contains the batch file itself:

D:\>jshell\jshell.cmd

D:\>D:\jshell\bin\jshell -v --start DEFAULT --start PRINTING
|  Welcome to JShell -- Version 10
|  For an introduction type: /help intro

jshell>

For added browny points, add @echo off as the first line to suppress the commands being echod:

D:\>jshell\jshell.cmd
|  Welcome to JShell -- Version 10
|  For an introduction type: /help intro

jshell>

Thanks for the input. I've changed the batch file to:

@echo off
"%~dp0bin\jshell" -v --start DEFAULT --start PRINTING