运行可执行文件,然后等待该特定的exe文件不再运行 [英] running an Executable file and then waiting for that particular exe file to no longer be running

查看:90
本文介绍了运行可执行文件,然后等待该特定的exe文件不再运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想运行一个AHK可执行文件然后让java等待该可执行文件在它的脚本结束时终止它自己的进程然后继续,是否有一个函数来监视特定的exe是否正在运行?如果它正在运行以等到它已经停止?

I want to run an AHK executable and then have java wait for that executable to terminate it's own process at the end of it's script and then continue, is there a function to monitor whether or not a particular exe is running? And if it's running to wait until it has stopped?

例如在AHK中你可以这样做:

for example in AHK you could do:

IfExist, Appname, 
{
insert code
}

我会用AHK做这个项目,但是因为AHK变量非常脆弱而且递增我无法正常工作它的IF和Else语句正确

I would do this project using just AHK but because AHK is so flimsy with variables and incrementing i can't get it to work it's IF and Else Statements properly

或者如果可能的话,我如何让Java暂停一段时间

or if even possible, how can i make Java pause itself for a period of time

所有我真正想要的是运行一个简单的代码.exe和等待它不存在的代码

all im really looking for is a simple bit of code to run a .exe and the a bit fo code to wait for it to not exist

推荐答案

它就像一行代码一样简单:

It is as simple as one line of code:

Runtime.getRuntime().exec(<insert executable file here>).waitfor();

PS:这只是一行,所以我不介意,但这不是一个地方从他人那里获得完整的工作代码通常的回答是看看这里,自己动手,除非OP发布相关代码并丢失一小部分,这不是这里的情况。

PS2:请考虑接受Jim的答案,因为它是纠正一个。

PS: It is just one line so I didn't mind, but this is not a place to obtain full working code from others. The usual response is "look here, do it yourself", unless the OP post relevant code with a small part missing, which is not the case here.
PS2: Please consider accepting Jim's answer as it was the correct one.

这篇关于运行可执行文件,然后等待该特定的exe文件不再运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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