Any way to identify an application by Window title?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
MKANET
Posts: 160
Joined: 31 Mar 2012 21:31

Any way to identify an application by Window title?

#1 Post by MKANET » 31 May 2012 16:34

Is there a way to identify a process by it's window title? Specifically, I need a batch file to close a specific Explorer window with the title Logs

I'm not sure if the tasklist command can do it. It does mention WINDOWTITLE. However, I couldn't find one good example to try when searching on google. Heck, I dont even know if it's possible with any native command.

Thanks in advance,
MKANET

MKANET
Posts: 160
Joined: 31 Mar 2012 21:31

Re: Any way to identify an application by Window title?

#2 Post by MKANET » 31 May 2012 16:37

I think I got it! I was almost there...

tasklist /fi "WINDOWTITLE eq Logs"

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Any way to identify an application by Window title?

#3 Post by Squashman » 31 May 2012 19:55

Pretty sure if you read the help from the cmd window you could see some examples.

MKANET
Posts: 160
Joined: 31 Mar 2012 21:31

Re: Any way to identify an application by Window title?

#4 Post by MKANET » 31 May 2012 22:07

Hopefully, that should go without saying. :) Tasklist /?, as well as, and the first couple of MS website didn't have any real-life examples I could follow. Luckily, I found a URL which used this command in a normal real-life example.

Squashman wrote:Pretty sure if you read the help from the cmd window you could see some examples.

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Any way to identify an application by Window title?

#5 Post by Squashman » 01 Jun 2012 06:03

TASKLIST help shows exactly how to use the FILTERS. Do you expect Microsoft to put every possible filter combination into the examples when really only one is needed. It works the same for all the Filters. It would be redundant!

Code: Select all

Filters:
    Filter Name     Valid Operators           Valid Value(s)
    -----------     ---------------           --------------
    STATUS          eq, ne                    RUNNING | NOT RESPONDING
    IMAGENAME       eq, ne                    Image name
    PID             eq, ne, gt, lt, ge, le    PID value
    SESSION         eq, ne, gt, lt, ge, le    Session number
    SESSIONNAME     eq, ne                    Session name
    CPUTIME         eq, ne, gt, lt, ge, le    CPU time in the format
                                              of hh:mm:ss.
                                              hh - hours,
                                              mm - minutes, ss - seconds
    MEMUSAGE        eq, ne, gt, lt, ge, le    Memory usage in KB
    USERNAME        eq, ne                    User name in [domain\]user
                                              format
    SERVICES        eq, ne                    Service name
    WINDOWTITLE     eq, ne                    Window title
    MODULES         eq, ne                    DLL name

Examples:
    TASKLIST
    TASKLIST /M
    TASKLIST /V
    TASKLIST /SVC
    TASKLIST /M wbem*
    TASKLIST /S system /FO LIST
    TASKLIST /S system /U domain\username /FO CSV /NH
    TASKLIST /S system /U username /P password /FO TABLE /NH
    TASKLIST /FI "USERNAME ne NT AUTHORITY\SYSTEM" /FI "STATUS eq running"

How do you not extrapolate from that how to use all the Filters?

Post Reply