(PECL win32service SVN)
win32_create_service — Creates a new service entry in the SCM database
An array of service details:
The short name of the service. This is the name that you will use to control the service using the net command. The service must be unique (no two services can share the same name), and, ideally, should avoid having spaces in the name.
The display name of the service. This is the name that you will see in the Services Applet.
The long description of the service. This is the description that you will see in the Services Applet.
The name of the user account under which you want the service to run. If omitted, the service will run as the LocalSystem account. If the username is specified, you must also provide a password.
The password that corresponds to the
The full path to the executable module that will be launched when the service is started. If omitted, the path to the current PHP process will be used.
Command line parameters to pass to the service when it starts. If you want to run a PHP script as the service, then the first parameter should be the full path to the PHP script that you intend to run. If the script name or path contains spaces, then wrap the full path to the PHP script with ".
Controls the load_order. This is not yet fully supported.
Sets the service type. If omitted, the default value is
Don't change this unless you know what you're doing.
Specifies how the service should be started. The default is
WIN32_SERVICE_AUTO_START which means the
service will be launched when the machine starts up.
Informs the SCM what it should do when it detects a problem with
the service. The default is
WIN32_SERVER_ERROR_IGNORE. Changing this
value is not yet fully supported.
delayed_start is set to
TRUE, then this
will inform the SCM that this service should be started after other
auto-start services are started plus a short delay.
Any service can be marked as a delayed auto-start service; however,
this setting has no effect unless the service's
This setting is only applicable on Windows Vista and Windows Server 2008 or greater.
To reduce the impact on processor utilisation, it may be necessary to set a base priority lower than normal.
base_priority can be set to one of the
constants define in
Win32 Base Priority Classes.
The optional machine name on which you want to create a service. If omitted, it will use the local machine.
WIN32_NO_ERROR on success,
FALSE if there is a problem with the parameters or a Win32 Error Code on failure.
Example #1 A win32_create_service() example
Create a service with the short name 'dummyphp'.
$x = win32_create_service(array(
'service' => 'dummyphp', # the name of your service
'display' => 'sample dummy PHP service', # short description
'description' => 'This is a dummy Windows service created using PHP.', # long description
'params' => '"' . __FILE__ . '" run', # path to the script and parameters