<div class="content" name="RStartServiceA" uuid="f15fc391-8576-4e30-b158-75c306e1cba2"><p>The RStartServiceA method starts a specified service.</p><dl>
<dd>
<div><pre> DWORD RStartServiceA(
   [in] SC_RPC_HANDLE hService,
   [in, range(0, SC_MAX_ARGUMENTS)] 
     DWORD argc,
   [in, unique, size_is(argc)] LPSTRING_PTRSA argv
 );
</pre></div>
</dd></dl><p><b>hService: </b>An <span><a href="b5f0a0a8-887c-4097-af1c-71ef9f214ce4" data-linktype="relative-path">SC_RPC_HANDLE (section 2.2.4)</a></span>
that defines the handle to the <span><a href="4f66d32e-2f4f-4482-998e-e5ccbb445223#gt_1fbb7936-8437-4e3d-b62f-47df3be07721" data-linktype="relative-path">service record</a></span> that
MUST have been created previously, using one of the open methods specified in
section <span><a href="0d7a7011-9f41-470d-ad52-8535b47ac282" data-linktype="relative-path">3.1.4</a></span>. The
SERVICE_START access right MUST have been granted to the caller when the <span><a href="4f66d32e-2f4f-4482-998e-e5ccbb445223#gt_9dfe84e3-a772-4ad1-9a25-1255c1dc0f84" data-linktype="relative-path">RPC
context handle</a></span> was created.</p><p><b>argc: </b>The number of argument strings in the <i>argv</i>
array. If <i>argv</i> is NULL, this parameter MAY be zero.</p><p><b>argv: </b>A pointer to a buffer that contains an
array of pointers to null-terminated ANSI strings that are passed as arguments
to the service.</p><p><b>Return Values: </b>The method returns 0x00000000
(ERROR_SUCCESS) on success; otherwise, it returns one of the following error
codes.<a id="Appendix_A_Target_46"></a><a aria-label="Product behavior note 46" href="041d2a89-9d7d-4f79-91a1-c336d0a668f6#Appendix_A_46" data-linktype="relative-path">&lt;46&gt;</a></p><dl>
<dd>
<table><thead>
  <tr>
   <th>
   <p>Return value/code</p>
   </th>
   <th>
   <p>Description</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>2 ERROR_FILE_NOT_FOUND</td>
  <td>The system cannot find the file specified.</td>
 </tr><tr>
  <td>3 ERROR_PATH_NOT_FOUND</td>
  <td>The system cannot find the path specified.</td>
 </tr><tr>
  <td>5 ERROR_ACCESS_DENIED</td>
  <td>The SERVICE_START access right had not been granted to the caller when the RPC context handle to the service was created.</td>
 </tr><tr>
  <td>6 ERROR_INVALID_HANDLE</td>
  <td>The handle is no longer valid.</td>
 </tr><tr>
  <td>87 ERROR_INVALID_PARAMETER</td>
  <td>A parameter that was specified is invalid.</td>
 </tr><tr>
  <td>1053 ERROR_SERVICE_REQUEST_TIMEOUT</td>
  <td>The process for the service was started, but it did not respond within an implementation-specific time-out.&lt;47&gt;</td>
 </tr><tr>
  <td>1054 ERROR_SERVICE_NO_THREAD</td>
  <td>A thread could not be created for the service.</td>
 </tr><tr>
  <td>1055 ERROR_SERVICE_DATABASE_LOCKED</td>
  <td>The service database is locked by the call to the RLockServiceDatabase (section 3.1.4.4) method.&lt;48&gt;</td>
 </tr><tr>
  <td>1056 ERROR_SERVICE_ALREADY_RUNNING</td>
  <td>The ServiceStatus.dwCurrentState in the service record is not set to SERVICE_STOPPED.</td>
 </tr><tr>
  <td>1058 ERROR_SERVICE_DISABLED</td>
  <td>The service cannot be started because the Start field in the service record is set to SERVICE_DISABLED.</td>
 </tr><tr>
  <td>1068 ERROR_SERVICE_DEPENDENCY_FAIL</td>
  <td>The specified service depends on another service that has failed to start.</td>
 </tr><tr>
  <td>1069 ERROR_SERVICE_LOGON_FAILED</td>
  <td>The service did not start due to a logon failure.</td>
 </tr><tr>
  <td>1072 ERROR_SERVICE_MARKED_FOR_DELETE</td>
  <td>The RDeleteService method has been called for the service record identified by the hService parameter.</td>
 </tr><tr>
  <td>1075 ERROR_SERVICE_DEPENDENCY_DELETED</td>
  <td>The specified service depends on a service that does not exist or has been marked for deletion.</td>
 </tr><tr>
  <td>1115 ERROR_SHUTDOWN_IN_PROGRESS</td>
  <td>The system is shutting down.</td>
 </tr></tbody></table>
</dd></dl><p>In response to this request from the client, for a
successful operation the server MUST start the service using the information
from the service record identified by the hService parameter and pass the
arguments specified in the argv parameter as part of the service launch
command.</p><p>If <i>argv</i> is not NULL, the client SHOULD set the first
element in <i>argv</i> to the name of the service.</p><p>The server MUST ignore <i>argv</i> for service records with <b>Type</b>
equal to SERVICE_KERNEL_DRIVER or SERVICE_FILE_SYSTEM_DRIVER.</p><p>The server MUST set the <b>ServiceStatus.dwCurrentState</b>
in the service record, as specified in <span><a href="4e91ff36-ab5f-49ed-a43d-a308e72b0b3c" data-linktype="relative-path">SERVICE_STATUS (section 2.2.47)</a></span>,
to SERVICE_START_PENDING.</p><p>The server MUST set the <b>ServiceStatus.dwControlsAccepted</b>
in the service record, as specified in SERVICE_STATUS, to none (zero).</p><p>The server MUST set the <b>ServiceStatus.dwCheckPoint</b> in
the service record, as specified in SERVICE_STATUS, to zero.</p><p>The server MUST set the <b>ServiceStatus.dwWaitHint</b> in
the service record, as specified in SERVICE_STATUS, to 2 seconds.</p><p>The server MUST return ERROR_SERVICE_NO_THREAD if it is
unable to create a new thread for the service process.</p><p>If <i>argv</i> does not contain as many non-NULL pointers as
indicated by <i>argc</i>, the server MUST fail the call with
ERROR_INVALID_PARAMETER (87).</p></div>