停止使用批处理文件启动的进程
我从我的java代码启动一个批处理文件,使用
Runtime.getRuntime().exec("cmd /c start myFile.bat");
它依次启动一个应用程序,现在我想停止由这个批处理文件启动的应用程序,如何实现它。可能存在这样的情况:同一应用程序的相同多个实例已经在运行,但我想停止由该批处理文件启动的实例。有可能吗,我的服务器是在windows上。
因为这是游戏应用程序并且需要环境也尝试过
Runtime rt = Runtime.getRuntime() ;
Process p = rt.exec("C:/Valve/HLServer/hlds.exe +maxplayers 32 -game cstrike -console +port 27015 -nojoy -noipx -heapsize 250000 +map cs_italy +servercfgfile server.cfg +lservercfgfile +mapcyclefile mapcycle.txt +motdfile motd.txt +logsdir logs -zone 2048",null, new File("C:/Valve/HLServer")) ;
但仍然没有运气:(
i launch a batch file from my java code using
Runtime.getRuntime().exec("cmd /c start myFile.bat");
which in turn launches an application, now i want to stop the application been launched by this batch file, how to achieve it. there may be the case that the same multiple instance of same application are already running, but i want to stop the one being launched by this batch file. is it possible, my server is on windows.
since this was game application and need the enviroment also tried
Runtime rt = Runtime.getRuntime() ;
Process p = rt.exec("C:/Valve/HLServer/hlds.exe +maxplayers 32 -game cstrike -console +port 27015 -nojoy -noipx -heapsize 250000 +map cs_italy +servercfgfile server.cfg +lservercfgfile +mapcyclefile mapcycle.txt +motdfile motd.txt +logsdir logs -zone 2048",null, new File("C:/Valve/HLServer")) ;
but still no luck :(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
getRuntime( )
方法返回处理
类的对象并使用Process
可以调用的对象destroy()< Process 对象上的 /code>
方法用于终止进程
getRuntime()
method returnsProcess
class's object and using theProcess
object you can calldestroy()
method on the Process object to kill the process他是对的
,这样做
he is right
do this