windows 使用脚本杀死 cmd 或 shell 中的进程

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13003220/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 10:00:10  来源:igfitidea点击:

Killing a process in cmd or shell using a script

windowsshellprocessbatch-filecmd

提问by Takarakaka

How to implement using a shell or command line script in Windows that checks for the status of some process, ie. Tomcat server and if it exists, it kills it?

如何在 Windows 中使用 shell 或命令行脚本来检查某个进程的状态,即。Tomcat 服务器,如果它存在,它会杀死它吗?

回答by JKirchartz

On window you can make a .batfile with this content:

在窗口上,您可以.bat使用以下内容制作文件:

TASKKILL /F /IM "program_name.exe"

replace program_name with the program you want to kill. Here's a decent article on TASKKILL

将 program_name 替换为您要杀死的程序。这里有一篇不错的文章TASKKILL

Or if it's just tomcat you can run shutdown.bat... if TOMCAT_HOMEisn't set just run it from the tomcat home directory.

或者,如果它只是 tomcat,你可以运行shutdown.bat……如果TOMCAT_HOME没有设置,只需从 tomcat 主目录运行它。