Running jar with dropped file on bat
I want to drag and drop a file o开发者_JAVA技巧n a .bat file. After I dropped it I want to run a jar file with the dropped file path as input. How can I accomplish to run the jar file with a relative path? The dir my .bat file is run is my user dir and not the dir where it is located.
goal: cmd /c java -jar myjar.jar -f %1
current: cmd /c java -jar c:\somewhere\myjar.jar -f %1
The point is, that the program(jar +bat) is part of a small automated deploy process and for every user there might be a different path to run the jar.
Perhaps this works, it changed the current directory to the path of the batch-file
pushd "%~dp0"
cmd /c java -jar myjar.jar -f "%~1"
精彩评论