[英]Batch file to run close file if already running (scheduled job)
So I've run into an interesting problem, where I made a program in java that seems to have crashed once. 因此,我遇到了一个有趣的问题,我在Java中制作了一个似乎曾经崩溃过的程序。 I don't know the exact conditions that caused it to crash (since it seemingly stopped logging for that period of time).
我不知道导致它崩溃的确切条件(因为它在这段时间内似乎停止了日志记录)。 However it is being called via a batch file (that runs:
但是,它是通过一个批处理文件(运行:
java -jar MyProg.jar
) )
With that said, when the program failed to execute properly (despite some amount of safety nets in place) it stopped running when it should have. 话虽如此,当程序无法正确执行(尽管有一些安全网)时,它应该在应有的状态下停止运行。 Is there some way that I can check to see if user x is running java.exe, and if they are, do a:
有什么办法可以检查用户x是否正在运行java.exe,如果存在,请执行以下操作:
taskkill /IM java.exe /f
Before I try to run my program or something similar? 在尝试运行程序或类似程序之前? Thanks.
谢谢。
tasklist /nh /fi "imagename eq java.exe" | find /i "java.exe" >nul && taskkill /im java.exe /f || rem Java not running, run your program
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.