With lots of research, I've got to this point:
tasklist /fi "pid eq 13584" /fo CSV
Output:
"Image Name","PID","Session Name","Session#","Mem Usage"
"php.exe","13584","Console","1","25 660 K"
It is still an ugly mess. I'm trying to get output such as:
25660000
That is, no CSV or other "formatting"/unwanted data. No "formatted" amount of memory. Just raw bytes.
How is it done?
Calling some external program and parsing its output is never going to be ideal, but here we go:
This almost works. You still have to remove the space and multiply by 1000, but doing that in PHP is easier than in batch code. It relies a bit too much on how tasklist outputs the data, and this is probably not something you should use in production.
But we can do better: