1

サーバーを実行していWindows 7 64bit for WAMP 2ます。

for exbatch scriptを使用してプログラムを実行しています:Windows Com Component

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);

実行中のプログラムの数がわかる"cmd.exe"と、以下のコマンドを使用してすべてのプロセスが一覧表示されます。

tasklist /svc /fi "imagename eq cmd.exe"

そして、phpスクリプトを使用して以下のコマンドでそれらを殺します:

$output = shell_exec('taskkill /F /IM "cmd.exe"');

ここで、すべてのcmd.exeウィンドウが閉じられるわけではありません。

上記のコードで何がエラーになる可能性がありますか?Some windows are closed, while some remains open which is executing the command.

助けてください。

4

1 に答える 1

1

解決策を見つけました[より良い提案のために開いています]

最初にcheck and killif php tasks exists、次にcommand prompt will kill:

// It will first list out all `php.exe` tasks running
$output = shell_exec('tasklist /svc /fi "imagename eq php.exe"');
print_r($output);
echo "<br> ------------------------------------ <br>";

// It will first list out all `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'));

それがすべてに役立つことを願っています!

于 2013-07-22T09:20:52.547 に答える