# Actions: Services

install4j BeanInfo catalog. Each entry below documents a bean class that can appear inside a `<serializedBean>` element in an install4j project file.

## Contents

- [Install a service](#install-a-service) — `com.install4j.runtime.beans.actions.services.InstallServiceAction`
- [Start a service](#start-a-service) — `com.install4j.runtime.beans.actions.services.StartServiceAction`
- [Stop a service](#stop-a-service) — `com.install4j.runtime.beans.actions.services.StopServiceAction`

---

### Install a service
- **Class:** `com.install4j.runtime.beans.actions.services.InstallServiceAction`
- **Category:** Services
- **Multiple instances:** yes

Installs a service. On Windows, this is done by executing the service launcher with the appropriate arguments. On Unix, if systemd is detected, a config file will be created in /etc/systemd/system, otherwise a link will be placed in /etc/init.d. On macOS, a LaunchDaemon will be created. This action will be automatically reverted by the 'Uninstall files' action.If a helper process with elevated privileges has been created by the "Request privileges" action, this action is pushed to the helper process. Please see the help topic on "Elevation Of Privileges" for more information.

| Property | Type | Category | Visible when | Description |
|---|---|---|---|---|
| `launcherId` — Service | String [context=serviceLauncher] | General | — | The service launcher that will be installed. |
| `executable` — Executable | File | General | `launcherId` (custom condition) | The service executable. |
| `serviceName` — Name | String | General | `launcherId` (custom condition) | The name of the service. |
| `autoStart` — Auto start | boolean | General | — | If the service should be started automatically at boot time. |
| `description` — Description | String | General | — | An optional description for the service. |
| `accountNameOrSid` — Account name or SID | String | Windows | `serviceAccount`=Other | The account name or a SID in String form. |
| `password` — Password | String | Windows | `serviceAccount`=Other | The password for the specified account. |
| `windowsArguments` — Windows arguments | String | Windows | — | Optional arguments passed to the main function of the service executable. |
| `windowsDependencies` — Windows dependencies | String | Windows | — | Optional dependencies for Windows. Specify as a comma-separated list of services that must be started before this service. You do not have to enter core OS services these services will always be initialized before your service is launched. |
| `windowsDisplayName` — Windows custom display name | String | Windows | — | Optional display name for the service. If empty, the service name is used. |
| `windowsPriority` — Windows priority | [WindowsPriority](enums.md#windowspriority) | Windows | — | The base priority class for the service. This only applies to services generated by install4j. |
| `serviceAccount` — Account | [ServiceAccount](enums.md#serviceaccount) | Windows | — | The account the service should run under. Use Local System if you are not sure what you need. |
| `keepCurrentAccount` — Keep current account | boolean | Windows | — | If the service was already installed, use the currently specified account instead of the values above. |
| `restartOnFailure` — Restart on failure | boolean | Windows | — | If the service should be automatically restarted if it doesn't exit with exit code 0 or if it crashes. |
| `restartMillis` — Restart after milliseconds | int | Windows | `restartOnFailure`=true | The time to wait before restarting the service after a failure, in milliseconds. |
| `maxRestarts` — Maximum number of restarts | int | Windows | `restartOnFailure`=true | The maximum number of restarts that should be performed. Enter 0 to not limit the number of restarts.This failure count can be reset after a period without failures by setting the "Reset failure count after seconds" property to a non-zero value. |
| `resetSeconds` — Reset failure count after seconds | int | Windows | `restartOnFailure`=true | The time after which to reset the failure count for the maximum number of restarts to zero if there are no further failures, in seconds. Enter 0 to indicate that the failure count should never be reset. |
| `interactive` — Interactive | boolean | Windows | — | If the service can interact with the desktop. Not recommended for Windows Vista and higher. |
| `delayedAutoStart` — Delayed auto start | boolean | Windows | — | If checked and "Auto Start" is also selected the service will be started after all other auto start services with an additional short delay. |
| `macosIdentifier` — macOS identifier | String | macOS | — | The launch daemon identifier for macOS. Typically, this is something like com.mycorp.myService. |
| `additionalSystemdEntries` — Additional systemd entries | String [context=multiline] | Unix | — | Optional additional entries for the systemd config file. If this property contains default entry types, the default values will be replaced. |

### Start a service
- **Class:** `com.install4j.runtime.beans.actions.services.StartServiceAction`
- **Category:** Services
- **Multiple instances:** yes

Starts a service by executing the service launcher with the appropriate arguments.If a helper process with elevated privileges has been created by the "Request privileges" action, this action is pushed to the helper process. Please see the help topic on "Elevation Of Privileges" for more information.

| Property | Type | Category | Visible when | Description |
|---|---|---|---|---|
| `launcherId` — Service | String [context=serviceLauncher] | General | — | The service launcher that will be started. |
| `executable` — Executable | File | General | `launcherId` (custom condition) | The service executable. |
| `serviceName` — Name | String | General | `launcherId` (custom condition) | The name of the service. |
| `autostartOnly` — For "Auto start installations" only | boolean | General | — | If selected, the service will only be started when it is installed as an "Auto start" service on Windows and macOS. This is a property on the "Install a service" action. |

### Stop a service
- **Class:** `com.install4j.runtime.beans.actions.services.StopServiceAction`
- **Category:** Services
- **Multiple instances:** yes

Stops a service by executing the service launcher with the appropriate arguments.If a helper process with elevated privileges has been created by the "Request privileges" action, this action is pushed to the helper process. Please see the help topic on "Elevation Of Privileges" for more information.

| Property | Type | Category | Visible when | Description |
|---|---|---|---|---|
| `launcherId` — Service | String [context=serviceLauncher] | General | — | The service launcher that will be stopped. |
| `executable` — Executable | File | General | `launcherId` (custom condition) | The service executable. |
| `serviceName` — Name | String | General | `launcherId` (custom condition) | The name of the service. |
| `windowsStopMinimumWaitTime` — Minimum wait time in ms | int | Windows | — | Minimum time the action waits for the service to shut down in milliseconds. |

