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 6766977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:53:45+00:00 2026-05-26T14:53:45+00:00

I need to set up a PHP script as a windows service. I need

  • 0

I need to set up a PHP script as a windows service.

I need it to run regardless of which user is logged in, and on system start up – so it sounds like a windows service is best, but am happy to hear other suggestions.

(This script runs continuously, it’s not a “run every 5 mins” thing I could use the Scheduled Task Manager for.)

http://support.microsoft.com/kb/251192 covers using the sc.exe program to install your service.

But from what I’ve read, I need to have a wrapper round the PHP script to accept the special commands from the windows service manager. Can anyone help with this?

  • 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-05-26T14:53:46+00:00Added an answer on May 26, 2026 at 2:53 pm

    Maybe the Resource Kit Tools (specifically srvany.exe) can help you here. MSDN: How To Create A User-Defined Service and possibly this hint for 2008 Server should help you setup any executable as a service. (I’ve successfully used this on Windows 2003 Server, Windows 2008 Server and on Windows XP Professional [other Resource Kit, though])

    You’d create a bat containing php your-script.php, wrap that with srvany.exe and voila, the script is started once the machine loads the services.

    srvany.exe should handle those start/stop/restart calls you’d expect a daemon to execute. It would load your executable on start, kill the process on stop, do both on restart. So you don’t have to worry about this part. You might want to check if a register_shutdown_function() can help identify when your service process is killed.

    You can even define dependencies to other services (say some database or some such).

    Windows Registry Editor Version 5.00
    
    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\THENAMEOFYOURSERVICE]
    "DependOnService"="DEPENDONTHIS"
    

    replace THENAMEOFYOURSERVICE with the name you gave your service and DEPENDONTHIS with the name of the service to depend on (say “Postgres9.0” or something). Save that file to dependency.reg and load it with regedit /s dependency.reg. (Or doubleclick it in explorer…)

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

Sidebar

Related Questions

i need to set a crontab from a php script. i know that it
for our project we need to set several PHP values depending on the environment
I have to run a get request from a PHP script, but I'm in
Ok guys.. I have a HTML i need to parse into a php script
Possible Duplicate: Using a javascript variable to set PHP variable I need to do
I need a way to include an external XML file in PHP which does
I need to code a PHP script that would let me generate a pdf
I have a php script which needs to connect to a database. The credentials
I have a php script that prompts the user to download a file: header(Content-Disposition:
I have a php script that runs on unix but I need it to

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.