taskkill window spaces in its title name

前端 未结 6 1882
耶瑟儿~
耶瑟儿~ 2020-12-13 13:33

I\'m trying to run taskkill on a console window that has spaces in it\'s title. How can I pass this window title to taskkill. I have tried the following:

tas         


        
6条回答
  •  猫巷女王i
    2020-12-13 14:19

    The trick is to name the cmd process and then kill it by calling the name you have given: The following is starting 6 parallel processes and you can kill any one of choice.

    start "cmd001" cmd.exe
    start "cmd002" cmd.exe
    start "cmd003" cmd.exe
    start "cmd004" cmd.exe
    start "cmd005" cmd.exe
    start "cmd 006" cmd.exe
    

    :: kill the process you want, e.g. cmd005

    taskkill /F /FI "WINDOWTITLE eq cmd005" /T
    

    :: kill a process which has a SPACE in its name, e.g. cmd 006

    taskkill /F /FI "WINDOWTITLE eq cmd 006" /T
    

提交回复
热议问题