Jump to content

Search the Community

Showing results for tags 'php windows services'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. i am trying to create php window service in window7 64 bit. I followed the instruction on http://php.net/manual/en/function.win32-create-service.php but it seem not to work for me. The create service did create service just fine. But when I do the start the service did not start and when doing win32_query_service_status I always get stop status. Any pointer would be greatly appreciated. <?php //No timeouts, Flush Content immediatly set_time_limit(0); ob_implicit_flush(); //Service Settings $phpPath = "D:/Zend/ZendServer/bin/"; $ServiceName = 'testscript'; $ServiceDisplay = 'test'; //Windows Service Control $ServiceAction = "status"; //$ServiceAction = "debug"; if ( isset($_GET['ServiceAction']) and strlen($_GET['ServiceAction']) ) { $ServiceAction = addslashes($_GET['ServiceAction']); } else if ( isset($argv) and isset($argv[1]) and strlen($argv[1]) ) { $ServiceAction = $argv[1]; } if( $ServiceAction == "status" ) { $ServiceStatus = win32_query_service_status($ServiceName); if ( $ServiceStatus['CurrentState'] == WIN32_SERVICE_STOPPED ) { echo "Service Stopped\n\n"; } else if ( $ServiceStatus['CurrentState'] == WIN32_SERVICE_START_PENDING ) { echo "Service Start Pending\n\n"; } else if ( $ServiceStatus['CurrentState'] == WIN32_SERVICE_STOP_PENDING ) { echo "Service Stop Pending\n\n"; } else if ( $ServiceStatus['CurrentState'] == WIN32_SERVICE_RUNNING ) { echo "Service Running\n\n"; } else if ( $ServiceStatus['CurrentState'] == WIN32_SERVICE_CONTINUE_PENDING ) { echo "Service Continue Pending\n\n"; } else if ( $ServiceStatus['CurrentState'] == WIN32_SERVICE_PAUSE_PENDING ) { echo "Service Pause Pending\n\n"; } else if ( $ServiceStatus['CurrentState'] == WIN32_SERVICE_PAUSED ) { echo "Service Paused\n\n"; } else{ echo "Service Unknown\n\n"; } exit; } else if ( $ServiceAction == "install" ) { //Install Windows Service win32_create_service( Array( 'service' => $ServiceName, 'display' => $ServiceDisplay, 'params' => __FILE__ . " run", 'path' => $phpPath."php.exe", )); echo "Service Installed\n\n"; exit; } else if ( $ServiceAction == "uninstall" ) { //Remove Windows Service win32_delete_service($ServiceName); echo "Service Removed\n\n"; exit; } else if( $ServiceAction == "start") { //Start Windows Service+ win32_start_service($ServiceName); $ServiceStatus = win32_query_service_status($ServiceName); var_dump($ServiceStatus); echo "Service Started\n\n"; exit; } else if( $ServiceAction == "stop" ) { //Stop Windows Service win32_stop_service($ServiceName); echo "Service Stopped\n\n"; exit; } else if ( $ServiceAction == "run" ) { //Run Windows Service win32_start_service_ctrl_dispatcher($ServiceName); win32_set_service_status(WIN32_SERVICE_RUNNING); } else if ( $ServiceAction == "debug" ) { //Debug Windows Service set_time_limit(10); } else { exit(); } //Server Loop while (1) { //Handle Windows Service Request usleep(100*1000); if ( $ServiceAction == "run" ) { switch ( win32_get_last_control_message() ) { case WIN32_SERVICE_CONTROL_CONTINUE: break; case WIN32_SERVICE_CONTROL_INTERROGATE: win32_set_service_status(WIN32_NO_ERROR); break; case WIN32_SERVICE_CONTROL_STOP: win32_set_service_status(WIN32_SERVICE_STOPPED); exit; default: win32_set_service_status(WIN32_ERROR_CALL_NOT_IMPLEMENTED); } } //User Loop sleep(1); $cnt = 0; $my_file = 'file.txt'; $handle = fopen($my_file, 'a'); fwrite($handle, "This is a test \n"); fclose($handle); } //Exit if ( $ServiceAction == "run" ) { win32_set_service_status(WIN32_SERVICE_STOPPED); } exit();
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.