Keith Keith - 1 year ago 117
C# Question

Credentials when Installing Windows Service

I am attempting to install a C# windows service project using a VisualStudio.Net deployment project.

To run the deployment project I right-click and select "install" from the context menu, the install wizard runs and eventually prompts me with a "Set Service Login" dialog which asks for username & password.

When I install a service using the sc utility from the command line, I don't have to provide credentials.

Do I have to create a login just for this service? I'd prefer to use "Local System" or "Network Service" (not sure what the difference is) as other services do.

Answer Source

Add this code to your private void InitializeComponent() method in projectInstaller.Designer.cs file in your windows service project.

this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalSystem;

if the definition of you process installer is:

private System.ServiceProcess.ServiceProcessInstaller serviceProcessInstaller1;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download