Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 927
Keith Avatar asked Feb 12 '10 15:02

Keith


2 Answers

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; 
like image 200
anthares Avatar answered Sep 21 '22 13:09

anthares


Check this Link: http://msdn.microsoft.com/en-us/library/zt39148a(v=vs.110).aspx

Pay attention to this section: To create the installers for your service

Make changes to your ServiceProcessInstaller:

In the designer, click ServiceProcessInstaller1 for a Visual Basic project, or serviceProcessInstaller1 for a Visual C# project. Set the Account property to LocalSystem. This will cause the service to be installed and to run on a local service account.

like image 43
David Avatar answered Sep 19 '22 13:09

David