exe4j Help

Services


On the "Executable info->Service options" step of the wizard you can configure further options for executables whose type has been set to "Service" on the "Executable info" step.

Windows services are installed by passing /install to the generated service executable. The default start mode of the service can be set as:

  • start on demand

    In start on demand mode, your service must be manually started by the user in the Windows service manager. Use this option, if you're not sure if your users will actually want to run your application as a service, but you want to give them an easy way to do so. This installation mode can be forced if the user passes /install-demand to the generated executable instead of /install.
  • auto start

    In auto start mode, your service is always started when Windows is booted. This installation mode can be forced if the user passes /install-auto to the generated executable instead of /install.

Windows services are always uninstalled by passing /uninstall to the generated service executable. All command line switches also work with a prefixed dash instead of a slash (like -uninstall) or two prefixed dashes (like --uninstall).

To start or stop the service, the /start, /stop and /restart options are available. In addition, a /status argument shows if the service is already running. The exit code of the status command is 0 when the service is running, 3 when it is not running and 1 when the state cannot be determined (for example when it is not installed).

As a second parameter after the /install parameter, you can optionally pass a service name. In that way you can

  • install a service with a different service name than the default name.
  • Use the same service executable to start multiple services with different names. To distinguish several running service instances at runtime, you can query the system property exe4j.launchName for the service name. Note that you also have to pass the same service name as the second parameter if you use the /uninstall, /start and /stop parameters.

For debugging purposes, you may want to run the executable on the command line without starting it as a service. This can be done with the /run parameter. In that case, all output will be printed on the console. If you want to keep the redirection settings, use the /run-redirect parameter instead.

If your service depends on another service, say a database, you can enter the service name of the other service in the Dependencies text field. You do not have to enter core OS services such as filesystem or network, these services will always be initialized before your service is launched. If you have dependencies on multiple services, you can enter a list of these service names separated by commas.