开发者

Running jar with dropped file on bat

开发者 https://www.devze.com 2023-02-17 10:00 出处:网络
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

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"
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号