Gets or sets the password associated with the user account under which the service application runs.
Assembly: System.ServiceProcess (in System.ServiceProcess.dll)
The and Username pair allows the service to run under an account other than the system account. This can, for example, allow the service to start automatically at reboot, when no user is logged on.
Setting the Username and allows an account to be associated automatically with the service at install time. If you leave either the Username or empty and set Account to User, you will be prompted for a valid user name and password at installation.
Another option for running a service under a separate account is to use the computer's System account. That account, which is distinct from the Administrator account, requires no password. The System account's privileges may exceed those of the user currently logged in. Running under the System account rather than a user account avoids problems resulting from the user lacking a permission the service requires