problem with TASKLIST /FI "WINDOWTITLE....."

Author Message
tonyboy2011

  • Total Posts : 2
  • Scores: 0
  • Reward points : 0
  • Joined: 2/5/2012
  • Status: offline
problem with TASKLIST /FI "WINDOWTITLE....." Monday, February 06, 2012 6:23 AM (permalink)
0
Hi folks...OK so i have ALMOST finished my first ever batch script.
 
My only remaining problem is that of windowtitle filter inside the tasklist function.
 
I am trying to select windows with "Kingdoms of Camelot on Facebook - Cometbird". However, the VERY annoying this about facebook is, every time you get a notification, it adds it to the title bar, making it "(1) Kingdoms of cam..."
 
Because of this, the WINDOWTITLE filter doesn't work for me, because it now contains (1) in the title.
 
Is there a way to make the wildcards * or ? work inside the filter???????
 
All i want is for it to accept (1) or (2) etc, at the start of the titlebar, and not return an errorlevel because of them...
 
Here is the relevant code section....
 
tasklist /FI "WINDOWTITLE eq Kingdoms of Camelot on Facebook - Cometbird"2>NUL | find /I /N "cometbird.exe"2>NUL
if "%ERRORLEVEL%"=="0" goto runningcomet
if "%ERRORLEVEL%"=="1" goto notrunningcomet
 
So if i get a notification in facebook, it no longer works because the title now is (1) Kingdoms of cam...etc.
 
tasklist /FI "WINDOWTITLE eq (1) Kingdoms of Camelot on Facebook - Cometbird"2>NUL | find /I /N "cometbird.exe"2>NUL
if "%ERRORLEVEL%"=="0" goto runningcomet
if "%ERRORLEVEL%"=="1" goto notrunningcomet
 
Would work fine, but i need to use some sort of wildcard. Is this possible in batch files? I am very novice so please be gentle.
 
#1
    59cobalt

    • Total Posts : 981
    • Scores: 91
    • Reward points : 0
    • Joined: 7/17/2011
    • Status: offline
    Re:problem with TASKLIST /FI "WINDOWTITLE....." Monday, February 06, 2012 8:45 PM (permalink)
    0
    tasklist doesn't support wildcard matches for the window title, but you could try the reverse approach:
    tasklist /fi "imagename eq cometbird.exe" /v /fo table /nh | find /i "kingdoms of camelot on facebook" 2>nul

     
    #2

      Online Bookmarks Sharing: Share/Bookmark

      Jump to:

      Current active users

      There are 0 members and 1 guests.

      Icon Legend and Permission

      • New Messages
      • No New Messages
      • Hot Topic w/ New Messages
      • Hot Topic w/o New Messages
      • Locked w/ New Messages
      • Locked w/o New Messages
      • Read Message
      • Post New Thread
      • Reply to message
      • Post New Poll
      • Submit Vote
      • Post reward post
      • Delete my own posts
      • Delete my own threads
      • Rate post

      2000-2012 ASPPlayground.NET Forum Version 3.9