# $cs.Service_Start

> Starts the named service and waits up to maxTimeout milliseconds for it to reach the Running state.

Source: https://docs.capaone.com/capainstaller/powerpacks/cs-service-start/  
Product: CapaInstaller — a separate CapaSystems product; do not apply this page to any other.

### Description

Starts the named service and waits up to `maxTimeout` milliseconds for it to reach the Running state. Throws an exception if the service doesn't exist, and also throws a timeout-related exception if it doesn't reach Running within `maxTimeout`.

### Syntax

$cs.Service_Start(string servicename, uint maxTimeout = 60000)

### Parameters

#### servicename (String)

Name of the service to start.

#### maxTimeout (UInt32)

Maximum time to wait, in milliseconds, for the service to reach the Running state. Defaults to `60000` (60 seconds).

### Return value

None.

### Example

**PowerShell**

Check the service exists before starting it:

```powershell
if ($cs.Service_Exist("gupdate"))
{
  $cs.Job_WriteLog("Starting gupdate service")
  $cs.Service_Start("gupdate")
}
```

Start a service right after installation and catch the exception if it fails or times out, without failing the whole install:

```powershell
try
{
  $cs.Job_WriteLog("Starting MyAppService after install")
  $cs.Service_Start("MyAppService", 90000)
}
catch
{
  $cs.Job_WriteLog("MyAppService failed to start within the timeout: $($_.Exception.Message)")
}
```

Start a service with a shorter timeout when it's expected to come up quickly, letting the exception propagate to fail the job if it doesn't:

```powershell
$cs.Job_WriteLog("Starting lightweight helper service")
$cs.Service_Start("MyHelperService", 15000)
```

### Related functions

[$cs.Service_Exist](/capainstaller/powerpacks/cs-service-exist/) [$cs.Service_Stop](/capainstaller/powerpacks/cs-service-stop/)
