Batch script to close all open Command Prompt windows

浪尽此生 提交于 2019-12-09 05:56:09

问题


I have a .cmd file which I call to open multiple instances of Command Prompt via:

launcher.cmd -fs
launcher.cmd -tds
launcher.cmd -fsd

Each command open a new command prompt.

So what I want to do is create a batch file to automatically close all the opened Command Prompt instead of manually doing it.


回答1:


Be carefull: you might kill more processes than you want:

taskkill /IM cmd.exe

You can add extra filters:

taskkill /IM cmd.exe /FI "WINDOWTITLE eq launcher*"

use

tasklist /FI "imagename eq cmd.exe " /V

to get a glimpse of what cmd.exe processes will be taskkill-ed

You could add the /F parameter to force the process to close but I would only use that if the process doesn't respond to a normal request.




回答2:


TASKKILL /F /IM cmd.exe /T 

good solution



来源:https://stackoverflow.com/questions/8667221/batch-script-to-close-all-open-command-prompt-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!