问题
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