Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I need to write a batch program to end all MS office communicator tasks with window titles (usually ending with pattern "- Conversation" .

I tried

taskkill /FI "WINDOWTITLE eq *Conversation" /IM communicator.exe

but the wildcard pattern starting with a '*' does not seem to work. Gives the folowing error

ERROR: The search filter cannot be recognized.

any suggestions for a workaround would be greatly appreciated!

share|improve this question
'*' Can't work in the beginning of the filtered text –  Ofiris Dec 10 '12 at 17:18

1 Answer 1

up vote 2 down vote accepted

Here’s a batch file partially inspired by this question by Rogier:

@echo off

for /F "delims=" %%a in ('tasklist /fo list /v') do (
      call :Sub %%a
exit /b

set Line=%*
set BOL4=%Line:~0,4%
set BOL13=%Line:~0,13%
set Value=%Line:~14%
if "%BOL4%"=="PID:" (
      set save_PID=%Value%
      exit /b
if "%BOL13%"=="Window Title:" (                          // Note . below.
      echo %Value% | findstr /r /c:"- Conversation.$" > nul
      if not errorlevel 1 (
            echo %save_PID%
            REM taskkill /pid %save_PID%
      exit /b
exit /b

I found that I needed to add a . at the end of the regular expression for the

echostring| findstr /rregular expression ending with $

form to work.  I’m guessing that echo is adding a CR or maybe an extra CRLF to the string, and that findstr is counting that as a character occurring between the string and the end of the line.

Obviously you will un-comment-out the taskkill command one you have tested this.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.