0

The current, horribly flawed, method I use is:

tasklist /FI "WINDOWTITLE eq BLABLABLA" /NH

The BLABLABLA part above is the current exact process title. (Don't even get me started on the fact that it doesn't get its own quotes and thus cannot be escaped/secured easily/properly.)

The problem with this is that as soon as the process title differs even one char, it is considered a different script according to this logic. For example, I have all kinds of helpful hints added to the window/process title all the time, such as:

Actual title (5 seconds left...)

And:

[FINISHED] Actual title

And:

Actual title (4 / 9 items left)

And:

Actual title (35% downloaded)

And so on. You get the point. The process title often changes, so it isn't reliable for checking for the unique script.

The only other way I have found is to refer to something they call "IMAGENAME" (which apparently means "executable name"):

tasklist /FI "IMAGENAME eq php.exe" ...

This is of course even worse since it will just list any php.exe script!

My experimentation with the "tasklist" command (using the --verbose output and reading its manual) doesn't reveal any mention of the file path or any unique-per-file id or anything like that.

Why can't it let me do something like this?

tasklist /FI "FILEPATH eq BLABLABLA" /NH

?

I have thought of keeping track of the running scripts myself, in the database, but it seems horribly inefficient and also unreliable when things don't go exactly as planned and whatnot. It would definitely feel the best to use an OS-provided command (unless PHP has this built in after all).

I do know that the "eq" filter accepts an asterisk in the right end, but that doesn't help me due to the above reasons.

Do I really have no other choice but to sit and parse the full tasklist output and attempt to remove any "dynamic" parts of the process titles so that I can count the number of running scripts with the "same" process title as the script running the code? It feels incredibly hackish and dumb. It cannot be the right way...

(PS: You know, I keep getting baffled over and over again over just how many "obvious" (to me only, apparently) things and features are just missing. It's the same thing on both Windows and Linux. Stuff which I consider the "bare minimum" is somehow considered as superfluous/useless by everyone else. It really makes me wonder...)

1 Answer 1

1

You may refine the results by using:

tasklist /fi "imagename eq php.exe" /v | find /i "Actual title"

You must log in to answer this question.

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