How to install a service under NetworkService account

ImportantThe following article uses options that are available starting with the Professional edition and project type.

The Java Service Tutorial explains how to install a service under the LocalSystem account. However, if you want to install a service for a specific user, you need to make sure this user has enough privileges to install and start system services.

Install a service under NetworkService

You can configure a service installation for a custom user which is present on the target machine by following these steps:

  1. open the project file resulted after the Java Service Tutorial or a project which successfully installs a service
  2. go to the Services page and select your service
  3. in the Service Properties page set the "User Name" field to NT AUTHORITY\NetworkService and leave the "Password" field empty.
  4. check Set "Log on as a service" policy for selected username option

You can verify if a user can log on as a service by using the "Local Security Policy" tool:

Control Panel -> Administrative Tools -> Local Security Policy\Local Policies\User Rights Assignment\Log on as a service

Installation fails

This can happen if the service is already installed on the machine or if the installation package is not running with administrator privileges.