5

I start a command window with a similar command:

start "DUMMYCOMMANDWINDOW"

I can then close the window using this command:

taskkill /FI "WINDOWTITLE EQ DUMMY*" /f /t

What I'd like to do, however, is to close the window based on its partial title. Something like this:

taskkill /FI "WINDOWTITLE EQ *COMMANDWINDOW" /f /t

Is there a way to do that?

1
  • It's not really documented, but you can use the * wildcard character only at the very end of the string.
    – and31415
    Jun 3, 2014 at 17:05

2 Answers 2

7

Using PowerShell, you can do the following:

Get-Process | Where-Object { $_.MainWindowTitle -like '*commandwindow' } | Stop-Process

Get-Process returns a list of all processes, the Where-Object clause filters it based on the window title, and Stop-Process is similar to taskkill.

1
  • Avoid trying this with -EQ operator! That doesn't work.. Wasted a few hours on the ideocyncracies of Powershell with that! Had to do <title>* syntax with -like. In my case all I wanted was the pId. so wrapped in brackets and used .Id
    – JGFMK
    May 5 at 5:54
1

An * cannot be at the start. Taskkill does not support it. But "COMMANDWINDOW*" should work regardless.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .