How can I simultaneously run dozens of PHP scripts in the background from XAMPP's command line interface?

Someone suggested a batch file, but when I tried executing this:

start php 1.php
start php 2.php
start php 3.php

It only opened a command prompt window; I closed that window, then two more command prompt windows opened up executing 2.php and 3.php.

I want to run as many scripts as I want all simultaneously and all in the background. What is the best way to accomplish this, and how can it be done?

EDIT Here is how to accomplish this:

1) Download PowerShell 2 (or the compatible version with your Windows version) from here: http://support.microsoft.com/kb/968929

2) Install it and restart your computer.

3) Make a new file "example.ps1" and save it to a directory of your choice (e.g. c:\examples\example.ps1). Put this code in that file:

start-job {.\c:\xampp\php\php C:\xampp\htdocs\phpfiles\1.php}
start-job {.\c:\xampp\php\php C:\xampp\htdocs\phpfiles\2.php}
start-job {.\c:\xampp\php\php C:\xampp\htdocs\phpfiles\3.php}
start-job {.\c:\xampp\php\php C:\xampp\htdocs\phpfiles\4.php}
start-job {.\c:\xampp\php\php C:\xampp\htdocs\phpfiles\5.php}
start-job {.\c:\xampp\php\php C:\xampp\htdocs\phpfiles\6.php}
start-job {.\c:\xampp\php\php C:\xampp\htdocs\phpfiles\7.php}
start-job {.\c:\xampp\php\php C:\xampp\htdocs\phpfiles\8.php}
start-job {.\c:\xampp\php\php C:\xampp\htdocs\phpfiles\9.php}
start-job {.\c:\xampp\php\php C:\xampp\htdocs\phpfiles\10.php}
start-job {.\c:\xampp\php\php C:\xampp\htdocs\phpfiles\11.php}

4) Click on "Start" -> "Run" and type in "powershell" (without quotes).

5) After PowerShell initiates, type in the following and press enter:

Set-ExecutionPolicy RemoteSigned

Then press "y" to set the changes.

6) Now type in (make sure to enter in the full file path):


7) To see your jobs simply type in:


To stop a job use this command:

stop-job JobName

1 Answer 1


Add some options after your start:

start /min cmd /c php -f 1.php

This will suppress the additional command prompts.

  • Thanks, but this only minimizes the 3 command prompt windows. Is there a way to run multiple scripts through CLI entirely in the background (in one window only)?
    – Pamela
    Aug 30, 2012 at 15:48
  • 1
    For that, you will need the POSIX capabilities of PowerShell. Look at this article: jtruher.spaces.live.com/blog/cns!7143DA6E51A2628D!130.entry Aug 30, 2012 at 15:55
  • 1
    Thanks! That article is a bit outdated as PowerShell now integrates background jobs. I've updated my question with the full instructions on how to accomplish this.
    – Pamela
    Aug 30, 2012 at 19:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.