<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Creates a new service entry in the SCM database</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.win32-continue-service.html">win32_continue_service</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.win32-delete-service.html">win32_delete_service</a></div> <div class="up"><a href="ref.win32service.html">win32service Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="function.win32-create-service" class="refentry"> <div class="refnamediv"> <h1 class="refname">win32_create_service</h1> <p class="verinfo">(PECL win32service SVN)</p><p class="refpurpose"><span class="refname">win32_create_service</span> — <span class="dc-title">Creates a new service entry in the SCM database</span></p> </div> <div class="refsect1 description" id="refsect1-function.win32-create-service-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <span class="methodname"><strong>win32_create_service</strong></span> ( <span class="methodparam"><span class="type">array</span> <code class="parameter">$details</code></span> [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$machine</code></span> ] )</div> </div> <div class="refsect1 parameters" id="refsect1-function.win32-create-service-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">details</code></em></span> <dd> <p class="para"> An array of service details: <dl> <dt> <span class="term"><em><code class="parameter">service</code></em></span> <dd> <p class="para"> The short name of the service. This is the name that you will use to control the service using the <em>net</em> command. The service must be unique (no two services can share the same name), and, ideally, should avoid having spaces in the name. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">display</code></em></span> <dd> <p class="para">The display name of the service. This is the name that you will see in the Services Applet. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">description</code></em></span> <dd> <p class="para">The long description of the service. This is the description that you will see in the Services Applet. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">user</code></em></span> <dd> <p class="para"> 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. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">password</code></em></span> <dd> <p class="para"> The password that corresponds to the <em><code class="parameter">user</code></em>. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">path</code></em></span> <dd> <p class="para"> 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. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">params</code></em></span> <dd> <p class="para"> 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 <em>"</em>. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">load_order</code></em></span> <dd> <p class="para"> Controls the load_order. This is not yet fully supported. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">svc_type</code></em></span> <dd> <p class="para"> Sets the service type. If omitted, the default value is <strong><code>WIN32_SERVICE_WIN32_OWN_PROCESS</code></strong>. Don't change this unless you know what you're doing. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">start_type</code></em></span> <dd> <p class="para"> Specifies how the service should be started. The default is <strong><code>WIN32_SERVICE_AUTO_START</code></strong> which means the service will be launched when the machine starts up. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">error_control</code></em></span> <dd> <p class="para"> Informs the SCM what it should do when it detects a problem with the service. The default is <strong><code>WIN32_SERVER_ERROR_IGNORE</code></strong>. Changing this value is not yet fully supported. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">delayed_start</code></em></span> <dd> <p class="para"> If <em><code class="parameter">delayed_start</code></em> is set to <strong><code>TRUE</code></strong>, then this will inform the SCM that this service should be started after other auto-start services are started plus a short delay. </p> <p class="para"> Any service can be marked as a delayed auto-start service; however, this setting has no effect unless the service's <em><code class="parameter">start_type</code></em> is <strong><code>WIN32_SERVICE_AUTO_START</code></strong>. </p> <p class="para"> This setting is only applicable on Windows Vista and Windows Server 2008 or greater. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">base_priority</code></em></span> <dd> <p class="para"> To reduce the impact on processor utilisation, it may be necessary to set a base priority lower than normal. </p> <p class="para"> The <em><code class="parameter">base_priority</code></em> can be set to one of the constants define in <a href="win32service.constants.basepriorities.html" class="link">Win32 Base Priority Classes</a>. </p> </dd> </dt> </dl> </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">machine</code></em></span> <dd> <p class="para"> The optional machine name on which you want to create a service. If omitted, it will use the local machine. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.win32-create-service-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns <strong><code>WIN32_NO_ERROR</code></strong> on success, <strong><code>FALSE</code></strong> if there is a problem with the parameters or a <a href="win32service.constants.errors.html" class="link">Win32 Error Code</a> on failure. </p> </div> <div class="refsect1 examples" id="refsect1-function.win32-create-service-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-5390"> <p><strong>Example #1 A <span class="function"><strong>win32_create_service()</strong></span> example</strong></p> <div class="example-contents"><p> Create a service with the short name 'dummyphp'. </p></div> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br />$x </span><span style="color: #007700">= </span><span style="color: #0000BB">win32_create_service</span><span style="color: #007700">(array(<br /> </span><span style="color: #DD0000">'service' </span><span style="color: #007700">=> </span><span style="color: #DD0000">'dummyphp'</span><span style="color: #007700">, </span><span style="color: #FF8000"># the name of your service<br /> </span><span style="color: #DD0000">'display' </span><span style="color: #007700">=> </span><span style="color: #DD0000">'sample dummy PHP service'</span><span style="color: #007700">, </span><span style="color: #FF8000"># short description<br /> </span><span style="color: #DD0000">'description' </span><span style="color: #007700">=> </span><span style="color: #DD0000">'This is a dummy Windows service created using PHP.'</span><span style="color: #007700">, </span><span style="color: #FF8000"># long description<br /> </span><span style="color: #DD0000">'params' </span><span style="color: #007700">=> </span><span style="color: #DD0000">'"' </span><span style="color: #007700">. </span><span style="color: #0000BB">__FILE__ </span><span style="color: #007700">. </span><span style="color: #DD0000">'" run'</span><span style="color: #007700">, </span><span style="color: #FF8000"># path to the script and parameters<br /></span><span style="color: #007700">));<br /></span><span style="color: #0000BB">debug_zval_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$x</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> </div> </p> </div> <div class="refsect1 seealso" id="refsect1-function.win32-create-service-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="function"><a href="function.win32-delete-service.html" class="function" rel="rdfs-seeAlso">win32_delete_service()</a> - Deletes a service entry from the SCM database</span></li> <li class="member"><a href="win32service.constants.basepriorities.html" class="link">Win32 Base Priority Classes</a></li> <li class="member"><a href="win32service.constants.errors.html" class="link">Win32 Error Codes</a></li> </ul> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.win32-continue-service.html">win32_continue_service</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.win32-delete-service.html">win32_delete_service</a></div> <div class="up"><a href="ref.win32service.html">win32service Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>