ServiceProcessInstaller.Username Property

Gets or sets the user account under which the service application will run.

Namespace:  System.ServiceProcess
Assembly:  System.ServiceProcess (in System.ServiceProcess.dll)

[BrowsableAttribute(false)]
[TypeConverterAttribute("System.Diagnostics.Design.StringValueConverter, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public string Username { get; set; }

Property Value

Type: System.String
The account under which the service should run. The default is an empty string ("").

The Username and Password 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.

Password and Username are handled in a secure manner in that they are never serialized or saved to the install state (the project installer's Installer.Context) or other location with public access.

Setting the Username and Password allows an account to be associated automatically with the service at install time. If you leave either the Username or Password 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

If Account is any value other than User, the specified account (local or network service, or local system) is used, even if the Username and Password properties are populated.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft