Windows service installation credentials

I am trying to install a C # Windows service project using a VisualStudio.Net deployment project.

To start the deployment project, right-click and select “install” from the context menu, the installation wizard will start and eventually offer me the “Install Login Service” dialog box, which asks for a username and password.

When I install the service using the sc utility from the command line, I do not need to provide credentials.

Do I need to create a login only for this service? I would prefer to use the “Local System” or “Network Service” (not sure what the difference is), as other services do.

+43
c # install windows-services
Feb 12 2018-10-12
source share
4 answers

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

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

if determining your installation process:

 private System.ServiceProcess.ServiceProcessInstaller serviceProcessInstaller1; 
+78
Feb 12 '10 at 15:57
source share

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

Check out this section: To create installers for your service.

Make changes to your ServiceProcessInstaller:

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

+14
May 21 '14 at 17:03
source share

In the project that contains the service, add the Installer class. Do it something like this:

 [RunInstaller(true)] public class MyServiceInstaller : Installer { public MyServiceInstaller() { ServiceProcessInstaller serviceProcessInstaller = new ServiceProcessInstaller(); serviceProcessInstaller.Account = ServiceAccount.LocalSystem; // Or whatever account you want var serviceInstaller = new ServiceInstaller { DisplayName = "Insert the display name here", StartType = ServiceStartMode.Automatic, // Or whatever startup type you want Description = "Insert a description for your service here", ServiceName = "Insert the service name here" }; Installers.Add(_serviceProcessInstaller); Installers.Add(serviceInstaller); } public override void Commit(IDictionary savedState) { base.Commit(savedState); // This will automatically start your service upon completion of the installation. try { var serviceController = new ServiceController("Insert the service name here"); serviceController.Start(); } catch { MessageBox.Show( "Insert a message stating that the service couldn't be started, and that the user will have to do it manually"); } } } 

Then, in the Solution Explorer, right-click the deployment project and select View> User Actions. Right-click on custom actions and select "Add custom action ...". Select the application folder and select the main output of the project that contains this service. Now, after installation, user actions will be performed ( Commit on top). You can add additional methods ( Install , Rollback , Uninstall ) if you need other custom actions.

+4
Feb 12 '10 at 16:06
source share
  • Open ProjectInstaller
  • Right-click ProcessInstaller and select Properties
  • In the "Account" drop-down list in the "Miscellaneous" section, select the account for which your service will work as

For more information about the various accounts and their privileges, see the following link:

http://msdn.microsoft.com/en-us/library/system.serviceprocess.serviceaccount.aspx

+2
Dec 18 '12 at 8:40
source share



All Articles