1

How can you run multiple exec instances from a for loop and run them separately (i.e. not have one dependent on another finishing before starting another)? I have the following code which is hopefully self explanatory:

for ($i = 0;$i < 5;$i++){
    exec('START '.$path.' '.PATH.'spawn.php "'."$type,$core".'"');
}

I have looked at php in background exec() function but it isn't a duplicate as I am using the START command and adding an & did not fix it.

I have tried /B as an option but additionally this didn't work - it just ran it in the background.

Community
  • 1
  • 1
Ukuser32
  • 2,147
  • 2
  • 22
  • 32

1 Answers1

1

Under windows you will need to do it a bit differently.

$runCommand = 'calc.exe';
$WshShell = new COM("WScript.Shell");
$oExec = $WshShell->Run($runCommand, 7, false);

This should help explain it http://www.somacon.com/p395.php

http://de2.php.net/manual/en/function.exec.php#43917

Jason K
  • 1,406
  • 1
  • 12
  • 15