0

It is necessary to obtain information about the process in php (php + IIS + WinServer 2012):

  • process_id - pid
  • parent process_id - ppid
  • username - username, whose name was launched the process displayed in the Task Manager in the "user"

I use two approaches

exec('C:\Windows\System32\tasklist.exe /FI "pid eq 99999" /FI "USERNAME eq MYUSERNAME"', $output);

If such a process is, it appears, but I can not get parent_process_id :(

If I use:

exec('C:\Windows\System32\wbem\wmic.exe process where 'parentprocessid=\"$ppid\"' get parentprocessid,processid"', $output);

I can not get username :(

Someone faced with a challenge or know how to get this information?

djmartini
  • 361
  • 1
  • 5
  • 18
  • I'm not sure if this can help. http://php.net/manual/en/function.posix-getppid.php – Marc Giroux Jul 26 '16 at 17:08
  • *Parent process ID* is useless information on Windows. It does get recorded, when a process is created, but it isn't being used for anything. A 'parent' process can terminate, while its children continue to run. At that point the process ID entry won't get updated, and now points to a non-existent process, or worse, to another process altogether, because process IDs do get reused. Have a look at this [Q&A](http://stackoverflow.com/q/185254/1889329). – IInspectable Jul 28 '16 at 10:17

1 Answers1

0

You can run both and group the results by process_id. Iterate both the result sets and find the process_id matches.

Lajos Arpad
  • 64,414
  • 37
  • 100
  • 175