# ServiceConfiguration

Import: `import com.install4j.api.windows.service.ServiceConfiguration;`

```java
public class ServiceConfiguration implements Serializable
```

The service configuration passed to [`WinServices`](WinServices.md). If you don't set a property, the original value will be preserved for existing services.

## Methods

| Signature | Returns | Description |
|---|---|---|
| [`binaryName(String)`](#binaryname-string) | `ServiceConfiguration` | The path to the binary. |
| [`displayName(String)`](#displayname-string) | `ServiceConfiguration` | The display name. |
| [`startType(ServiceStartType)`](#starttype-servicestarttype) | `ServiceConfiguration` | The start type |
| [`dependencies(String)`](#dependencies-string) | `ServiceConfiguration` | A comma-separated list of dependencies |
| [`description(String)`](#description-string) | `ServiceConfiguration` | An additional description for the service |
| [`delayedAutoStart(Boolean)`](#delayedautostart-boolean) | `ServiceConfiguration` | If startType is set to `AUTO`, you can specify with this property that the service is started with a short delay after all other auto-start services. |
| [`restartOnFailure(Boolean)`](#restartonfailure-boolean) | `ServiceConfiguration` | If set to true, the service will be restarted after a period defined with [`ServiceConfiguration.restartMillis`](ServiceConfiguration.md#restartmillis-int) (defaults to one second) if it was terminated with an error |
| [`restartMillis(int)`](#restartmillis-int) | `ServiceConfiguration` | The restart period when [`ServiceConfiguration.restartOnFailure`](ServiceConfiguration.md#restartonfailure-boolean) is set to true. |
| [`maxRestarts(int)`](#maxrestarts-int) | `ServiceConfiguration` | The maximum number of restarts when [`ServiceConfiguration.restartOnFailure`](ServiceConfiguration.md#restartonfailure-boolean) is set to true. |
| [`resetSeconds(int)`](#resetseconds-int) | `ServiceConfiguration` | The time without failure in seconds after which to reset the restart counter configured with [`ServiceConfiguration.maxRestarts`](ServiceConfiguration.md#maxrestarts-int). |
| [`serviceAccount(ServiceAccount)`](#serviceaccount-serviceaccount) | `ServiceConfiguration` | The service account to be used. |
| [`otherAccountName(String)`](#otheraccountname-string) | `ServiceConfiguration` | The service account name to be used. |
| [`otherAccountPassword(String)`](#otheraccountpassword-string) | `ServiceConfiguration` | The service account password to be used. |
| [`getRestartMillis()`](#getrestartmillis) | `Integer` |  |
| [`getMaxRestarts()`](#getmaxrestarts) | `Integer` |  |
| [`getResetSeconds()`](#getresetseconds) | `Integer` |  |

### binaryName(String)

```java
public ServiceConfiguration binaryName(String binaryName)
```

The path to the binary. This can be quoted and contain arguments


**Parameters:**

- `binaryName` — the binary name

**Returns:** this object

### displayName(String)

```java
public ServiceConfiguration displayName(String displayName)
```

The display name. This is different from the service name which serves as identifier.


**Parameters:**

- `displayName` — the display name

**Returns:** this object

### startType(ServiceStartType)

```java
public ServiceConfiguration startType(ServiceStartType startType)
```

The start type


**Parameters:**

- `startType` — the start type

**Returns:** this object

### dependencies(String)

```java
public ServiceConfiguration dependencies(String dependencies)
```

A comma-separated list of dependencies


**Parameters:**

- `dependencies` — the dependencies

**Returns:** this object

### description(String)

```java
public ServiceConfiguration description(String description)
```

An additional description for the service


**Parameters:**

- `description` — the description

**Returns:** this object

### delayedAutoStart(Boolean)

```java
public ServiceConfiguration delayedAutoStart(Boolean delayedAutoStart)
```

If startType is set to `AUTO`, you can specify with this property that the service is started with a short delay after all other auto-start services.


**Parameters:**

- `delayedAutoStart` — `true` if the service start should be delayed

**Returns:** this object

### restartOnFailure(Boolean)

```java
public ServiceConfiguration restartOnFailure(Boolean restartOnFailure)
```

If set to true, the service will be restarted after a period defined with [`ServiceConfiguration.restartMillis`](ServiceConfiguration.md#restartmillis-int) (defaults to one second) if it was terminated with an error


**Parameters:**

- `restartOnFailure` — `true` if a restart should be performed

**Returns:** this object

### restartMillis(int)

```java
public ServiceConfiguration restartMillis(int restartMillis)
```

The restart period when [`ServiceConfiguration.restartOnFailure`](ServiceConfiguration.md#restartonfailure-boolean) is set to true. Defaults to one second.


**Parameters:**

- `restartMillis` — the restart period in milliseconds

**Returns:** this object

### maxRestarts(int)

```java
public ServiceConfiguration maxRestarts(int maxRestarts)
```

The maximum number of restarts when [`ServiceConfiguration.restartOnFailure`](ServiceConfiguration.md#restartonfailure-boolean) is set to true. Defaults to 0, which means unlimited restarts. With [`ServiceConfiguration.resetSeconds`](ServiceConfiguration.md#resetseconds-int) you can define the period after which this counter will be reset.
This should be a value between 0 and 2 to fit into the Windows service UI.


**Parameters:**

- `maxRestarts` — the number of restarts to try

**Returns:** this object

### resetSeconds(int)

```java
public ServiceConfiguration resetSeconds(int resetSeconds)
```

The time without failure in seconds after which to reset the restart counter configured with [`ServiceConfiguration.maxRestarts`](ServiceConfiguration.md#maxrestarts-int). Defaults to 0.


**Parameters:**

- `resetSeconds` — the time in seconds

**Returns:** this object

### serviceAccount(ServiceAccount)

```java
public ServiceConfiguration serviceAccount(ServiceAccount serviceAccount)
```

The service account to be used. Can be one of the predefined Windows accounts or `OTHER`. If it is `OTHER`, you have to specify
otherAccountName and otherAccountPassword


**Parameters:**

- `serviceAccount` — the account to be used

**Returns:** this object

### otherAccountName(String)

```java
public ServiceConfiguration otherAccountName(String otherAccountName)
```

The service account name to be used. The serviceAccount property will be set to `OTHER` when you call this method.
The name must be in the form DomainName\UserName. If the account belongs to the built-in domain, you can specify .\UserName.


**Parameters:**

- `otherAccountName` — the account name or SID

**Returns:** this object

### otherAccountPassword(String)

```java
public ServiceConfiguration otherAccountPassword(String otherAccountPassword)
```

The service account password to be used. The serviceAccount property will be set to `OTHER` when you call this method.


**Parameters:**

- `otherAccountPassword` — the account password

**Returns:** this object

### getRestartMillis()

```java
public Integer getRestartMillis()
```

### getMaxRestarts()

```java
public Integer getMaxRestarts()
```

### getResetSeconds()

```java
public Integer getResetSeconds()
```

## Constructors

| Signature | Description |
|---|---|
| [`ServiceConfiguration()`](#serviceconfiguration) |  |

### ServiceConfiguration()

```java
public ServiceConfiguration()
```

