在蝙蝠上运行jar与下降文件 [英] Running jar with dropped file on bat

查看:168
本文介绍了在蝙蝠上运行jar与下降文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将文件拖放到.bat文件中。删除它之后,我想运行一个带有删除文件路径的jar文件作为输入。如何使用相对路径运行jar文件?我的.bat文件运行的目录是我的用户目录,而不是它所在的目录。

I want to drag and drop a file on 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

关键是,程序(jar + bat)是小型自动部署过程的一部分,并且对于每个用户,可能有不同的路径来运行jar。

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"

这篇关于在蝙蝠上运行jar与下降文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆