batch processing - taskkill windows command prompt not killing all processes php -
i running windows 7 64bit wamp 2
server.
i running program batch script
using windows com component
ex:
c:\wamp\bin\php\php5.3.13\php.exe c:\wamp\www\test\command.php $wshshell = new com("wscript.shell"); $oexec = $wshshell->run($command, 7, false);
now when find how many "cmd.exe"
programs running, list me processes using below command:
tasklist /svc /fi "imagename eq cmd.exe"
and kill them below command using php script:
$output = shell_exec('taskkill /f /im "cmd.exe"');
here, happens is, not cmd.exe
windows getting closed.
what might error in above code? some windows closed, while remains open executing command.
please help.
found solution [though open better suggestions]
first needs check , kill
if php tasks exists
, command prompt kill
:
// first list out `php.exe` tasks running $output = shell_exec('tasklist /svc /fi "imagename eq php.exe"'); print_r($output); echo "<br> ------------------------------------ <br>"; // first list out `cmd.exe` tasks running $output = shell_exec('tasklist /svc /fi "imagename eq cmd.exe"'); print_r($output); echo "<br> ------------------------------------ <br>"; // kills php.exe tasks $php_output = shell_exec('taskkill /f /im "php.exe"'); print_r($output); echo "<br> ------------------------------------ <br>"; // kills cmd.exe tasks $cmd_output = shell_exec('taskkill /f /im "cmd.exe"'); print_r($output); echo "<br> ------------------------------------ <br>"; die(ucfirst('all tasks killed'));
hope helps !
Comments
Post a Comment