Ted
Ted

Reputation: 3875

How to run a php script asynchronously in Windows?

I am using xampp, in Windows 7.

in my understanding, calling a script this way should run the php.exe asynchronously and not wait for the script to end.

$run_cmd = "cmd c:/xampp/php/php.exe c:/xampp/htdocs/Gashash/batch_test.php";
$oExec = $WshShell->Run($run_cmd, 0, false);

of course:

$run_cmd = "cmd c:/xampp/php/php.exe c:/xampp/htdocs/Gashash/batch_test.php";
exec($run_cmd);

the exec() option doesn't work as desired as it halts the calling process until batch_test.php ends.

I tried using '\' and '\' as well as '/' for the slashes in the path but the script doesn't work!

Any suggestions ?

Thanks!

Upvotes: 0

Views: 2469

Answers (1)

user557846
user557846

Reputation:

Ii have answered this 3 times in the last week, please search first.

$WshShell = new COM("WScript.Shell");
$run_cmd = "cmd c:/xampp/php/php.exe c:/xampp/htdocs/Gashash/batch_test.php";
$WshShell = $WshShell->Run($run_cmd, 0, false);

Upvotes: 2

Related Questions