批量如何正确使用taskkill [英] in batch how do i use taskkill properly

查看:192
本文介绍了批量如何正确使用taskkill的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要关闭程序(minecraft服务器).我认为taskkill会完成工作

I need to shutdown a program (minecraft server). I think taskkill will do the job

@echo on
TASKKILL /F /IM Minecraft server /T
echo killed!

我问了在如何自动在其中键入停止"之前服务器的控制台,但是它们不起作用.我不想下载任何其他程序.只需批处理,VBScript或Java.不过,我还是希望批量处理.

I asked questions before of how to auto type "stop" in the console of the server, but they didn't work. I don't want to download any extra programs. Just batch, VBScript, or Java. I would prefer batch though.

希望我还是有道理的!

推荐答案

我认为您正在寻找这个东西:

I think you're looking for this:

@echo off
for /f "tokens=2" %%a in ('tasklist^|find /i "javaw.exe"') do (set pid=%%a)
echo %pid%
taskkill /pid %pid%
pause

这将获取PID(进程/任务的临时"ID"),并杀死它/源. 但是,这将需要一个随机的"javaw.exe",因此,如果一次打开多个"javaw.exe"/java进程,它将需要一个随机的"javaw.exe"/PID,然后将其杀死.但是根据我在运行Minecraft服务器时的经验,您不想在后台打开许多不必要的程序-因此,只要一次只运行一个'javaw.exe',就可以放心地使用它:)

This will get the PID (temporary "ID" for a proccess/task), and kill it/the source. This will take a random "javaw.exe" though, so if you have more than one 'javaw.exe' / java proccess open at a time, it will take a random one, find its' PID and kill it. But as for my experience when running a Minecraft server you dont want to have many unnessecary programs open in the Background - so you can safely use this as long as you only run one 'javaw.exe' at a time :)

希望获得帮助!

这篇关于批量如何正确使用taskkill的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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