I have script
pclose(popen("D: & cd D:\server\LoginServer & start /b startLoginServer.bat", "r"));
startloginserver.bat
starts java process and i need to get its pid to kill it when needed.
I'm new in these things.
Asked
Active
Viewed 437 times
0

Solo Omsarashvili
- 940
- 2
- 11
- 16
-
1You could use [proc_open](http://php.net/manual/en/function.proc-open.php) and [proc_close](http://php.net/manual/en/function.proc-close.php) instead and then use [proc_get_status](http://php.net/manual/en/function.proc-get-status.php) to get the pid – PhearOfRayne Jan 12 '13 at 07:28
-
Check out the solution in this question: http://stackoverflow.com/questions/4731637/killing-processes-opened-with-popen – Arnaud Jan 12 '13 at 07:32
1 Answers
0
In cmd to do it there's a command tasklist
.. will list the process with pid and then type taskkill /PID pid /F
.
Note: pid is the listed process id

Manoj Purohit
- 3,413
- 1
- 15
- 17
-
Is there any way to get pid after running exec or not? I mean to get pid when php finishes his work. – Solo Omsarashvili Jan 12 '13 at 07:31