-1

I have a little problem here and wondered if someone could explain this to me :)

when I type tasklist /V I get all my tasks and also the task I'm looking for:

So my process does have a WINDOWTITLE and its running and seen by tasklist... but when I type

tasklist /FI "WINDOWTITLE eq construction_tool_server"

or

tasklist /V /FI "WINDOWTITLE eq construction_tool_server"

I get an empty list -.-

What am I doing wrong? :)

Eryk Sun
  • 33,190
  • 5
  • 92
  • 111
User9132
  • 997
  • 1
  • 8
  • 15

2 Answers2

2

Thanks to BoogieMan2718 for your help :)

the problem was that i had spaces in my WINDOWTITLE

i changed the line

"title construction_tool_server && nodemon --watch server --exec babel-node -- ./server/server.js"

to

"title construction_tool_server&& nodemon --watch server --exec babel-node -- ./server/server.js"

and it works now :)

so thank you again :)

User9132
  • 997
  • 1
  • 8
  • 15
  • 1
    CMD's `title` command only strips white space from the beginning of the title, not the end. It's worse when CMD is run as admin. It prepends "Administrator: " to the title and (in what looks like a bug to me) it doesn't strip whitespace from the beginning of the user-provided title string. Due to how CMD parses the command line, there's always at least one space character at the start of the title, which is normally stripped, but when run as admin it remains. For example, `title WindowTitle` sets a title like "Administrator: WindowTitle", with two spaces after the colon. – Eryk Sun Jul 10 '17 at 18:21
0

The WINDOWTITLE Filter does not work on remote machines. Is this process on the local machine or a remote machine?

Also, does this command work for any other single local process besides construction_tool_server, or does it fail for any process you try?

You might try running CMD as administrator if you are not already.

BoogieMan2718
  • 109
  • 1
  • 10
  • 1st thank you for trying to help me :) it works fine for all other processes, or at least all i tried, I also tried to filter for another cmd and it worked ... its not remote all local , maybe it has something to do with npm and node.js which mess up something with the window propertys ? i dont know ... – User9132 Jul 10 '17 at 13:26
  • I open a cmd the title is "Eingabeauffoderung" i filter for its WindowTitle. it all works .... I switch to my server directory ... I type npm start server, which executes "title construction_tool_server && nodemon --watch server --exec babel-node -- ./server/server.js" ... the windowtitle of the cmd changes to "construction_tool_server" and the server starts all nicely, but from that point the cmd is not filtered by the name anymore, also not by its old name "Eingabeaufforderung" .... weired :D – User9132 Jul 10 '17 at 13:44
  • @User9132 Can you get it to return your desired result using this command? tasklist /V /FI "IMAGENAME eq cmd.exe" – BoogieMan2718 Jul 10 '17 at 13:53
  • yes :) but it also shows other cmd.exe prozesses ... I want PID of the one with "construction_tool_server" :D its crazy isnt it ? :D – User9132 Jul 10 '17 at 16:09
  • @User9132 I did notice that the WINDOWTITLE changed based on the most recent item entered into the CMD window. Maybe if you open one command prompt window and instantiate your construction_tool_server, then open another new CMD prompt window (leaving the original one open) and try your tasklist query it will work. – BoogieMan2718 Jul 10 '17 at 16:33
  • 1
    It's not a CMD window. The console host process (conhost.exe) creates the window, but for the sake of conveniently associating a console process with the console it's attached to, the Windows API fakes the initial attached process as the window owner. If that process exits, ownership is transferred to the next process in the console's list of attached processes, until the list is empty at which time the console destroys the window and exits. Frequently cmd.exe is the initial process, but it could be any other shell or REPL (e.g. run netsh.exe from Explorer). – Eryk Sun Jul 10 '17 at 17:49
  • 1
    Also, running cmd.exe as administrator adds a twist. When run with admin privileges, CMD calls the `SetConsoleTitleW` function with `Administrator: ` prepended to the title string. That's two spaces after the colon. – Eryk Sun Jul 10 '17 at 17:57