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:
taskkill /fi "WINDOWTITLE eq Administrator: My Window Title"
For starters, you can kill a program by using the following command: taskkill /F /IM winword.exe. Note that you have to use . EXE when using the TASKKILL command. /F means to forcefully terminate the process forcefully. /IM means the image name, i.e. the process name.
The taskkill command allows a user running any version of Microsoft Windows from XP on to "kill" a task from a Windows command line by PID (process id) or image name. This command is similar to end tasking a program in Windows.
I've had similar problems, but found out a little bit more.
I have been trying to close a CMD window (run as administrator) which has set its own window title. So, run CMD as administrator and type:
title CMD with custom title
After much faffing, the following command showed me that setting the window title puts a leading space in front of the title! (No idea why.)
c:\>tasklist /V /FI "WindowTitle eq Administrator*" Image Name PID Session Name Session# Mem Usage Status User Name CPU Time Window Title ========== ==== ============ ======== ========= ======= =============== ======== ===================================== cmd.exe 4304 Console 1 2,492 K Running MACHINE\My Name 0:00:00 Administrator: CMD with custom title 🡹 (scroll 🡺) extra space
So to kill the process:
taskkill /F /FI "WindowTitle eq Administrator: CMD with custom title" /T 🡹 bingo
/F
- use the force./T
- kill child-processes.If you're banging your head in a similar fashion, I recommend using tasklist
to poke around inside the process properties to make sure you're getting your filters right. This ballache brought to you by Windows 8.
Note: if the title contains quotation marks, just escape the nested ones:
title "CMD with custom title" taskkill /F /FI "WindowTitle eq Administrator: \"CMD with custom title\"" /T
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With