Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7771801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:44:19+00:00 2026-06-01T16:44:19+00:00

If I launch a PHP daemon in Windows with popen from a PHP script

  • 0

If I launch a PHP daemon in Windows with popen from a PHP script how do I check in a second time if that script is still running from a PHP script?

I’m with Apache, php as module

UPDATE:
process it’s started with

popen('start /b php process.php', 'r');

Once this is launched in windows a php.exe process is started. How do I get that process PID to later check (it runs for hours) from another PHP script if that process is still running?

I read this proc_open which is supposed to give the PID of the process launched along with proc_get_status but with that same command I use with popen nothing happens

UPDATE: I noticed with the same command and proc_open a php.exe process does start but it closes just after the script that launched it ends and the PID returned by proc_get_status doesn’t correspond to the Windows PID

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T16:44:20+00:00Added an answer on June 1, 2026 at 4:44 pm

    There are several ways of safely running processes with PHP and Windows:

    1. Start background process using the WScript.Shell object

    You can start the process using the Run method of the WScript.Shell object, which is built-in to Windows. By varying the second parameter, you can make the window hidden, visible, minimized, etc. By setting the third parameter to false, Run does not wait for the process to finish executing. This code only works on Windows. To find out more about COM, read PHP’s documentation.

    $WshShell = new COM("WScript.Shell");
    $oExec = $WshShell->Run("cmd /C dir /S %windir%", 0, false);
    

    2. Start background process using popen and pclose

    This code should work on Linux and Windows.

    pclose(popen("start \"bla\" \"" . $exe . "\" " . escapeshellarg($args), "r"));
    

    3. Start background process with psexec

    This method requires installing the freeware pstools from sysinternals:

    exec("psexec -d blah.bat"); 
    

    You can find out more information about it by reading this brief tutorial. I’ve used the first method before and it’s always worked for me.


    To find the PID of an existing process, I don’t think you can use getmypid or posix_getpid so you’ll have to use exec('tasklist');. Alternatively, you can install this extension and follow these instructions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a server with a PHP script that pulls data from a source
I'm trying to launch a CLI command from a PHP script: in particular I
I am writing a PHP script that will launch a program on the server.
I want to launch ~10 php processes from a bash script. When one of
I have a problem when I want to launch VLC from Apache using PHP.
I want launch simple php daemon on Ubuntu without fork. source f.php: #!/usr/bin/php <?php
You launch a java program from a console (maybe using a .bat script). I
I launch the following command line (process) from a Windows VC++ 6 program using
One page on my web site is a PHP script that uses exec() to
I have a PHP script launched from a command-line (aka CLI mode, no webserver

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.