简体   繁体   English

批处理文件以运行关闭文件(如果已运行)(计划的作业)

[英]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.

相关问题 文件可用后立即运行Spring Batch Job - Running Spring Batch Job as soon as the File is available 将批处理文件作为计划任务运行会不会表现出应有的作用? - Running a batch file as a scheduled task does not behave as it should? 将批处理文件作为计划任务运行时出错,Win Server 2008 - Error when running batch file as a scheduled task , win server 2008 testng.xml的批处理文件未按计划运行 - Batch file for testng.xml does not run as scheduled 尽管计划时间为5分钟,但Spring Batch Job阅读器仍在连续运行 - Spring Batch Job reader is running continuously although the scheduled time is 5 minutes 命令关闭 java 中的批处理文件 - command to close the batch file in java 在 java 中运行批处理文件 - Running batch file in java 通过Java运行批处理文件 - Running a batch file by java 如何在 1 个给定的 UAT 服务器中以计划模式运行 spring 批处理作业,但在所有 3 个给定的 UAT 服务器中运行手动作业? - How to run spring batch job in scheduled mode in 1 given UAT server, but run manual job in all 3 given UAT servers? 运行在最后一行中有“退出”的批处理文件后,命令提示符不会关闭 - Command prompt do not close after running batch file which have 'exit' in last line
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM