Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Windows service

Windows service

Scheduled Pinned Locked Moved C#
csharpvisual-studio
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    aurelcly
    wrote on last edited by
    #1

    Please I want to start automatically my service when I use installutil without start it manually.I set start property in automatic in visual studio but in service explorer I must start service once manually.But after this it's start itself. Thank you.

    D C M 3 Replies Last reply
    0
    • A aurelcly

      Please I want to start automatically my service when I use installutil without start it manually.I set start property in automatic in visual studio but in service explorer I must start service once manually.But after this it's start itself. Thank you.

      D Offline
      D Offline
      Dimitri Witkowski
      wrote on last edited by
      #2

      If you set start type to automatic, this means that your service will be started automatically when windows starts, and not when the installutil completes. If you want to start it after the installutil, you will need to run installutil first, and then run sc start <your_service_name>

      Die Energie der Welt ist konstant. Die Entropie der Welt strebt einem Maximum zu.

      1 Reply Last reply
      0
      • A aurelcly

        Please I want to start automatically my service when I use installutil without start it manually.I set start property in automatic in visual studio but in service explorer I must start service once manually.But after this it's start itself. Thank you.

        C Offline
        C Offline
        Calla
        wrote on last edited by
        #3

        You could also try creating a Setup Project where you run code to start your service as a Custom Action.

        ServiceController sc = new ServiceController("yourServiceName");
        sc.Start();

        1 Reply Last reply
        0
        • A aurelcly

          Please I want to start automatically my service when I use installutil without start it manually.I set start property in automatic in visual studio but in service explorer I must start service once manually.But after this it's start itself. Thank you.

          M Offline
          M Offline
          Mouldiwarp
          wrote on last edited by
          #4

          Hi, I got round that by adding a line into the projectinstaller.cs file. (Sorry, I hope I get the formatting right, I am new to contributing to this kind of forum.... and pretty new to C# and programming in general) After the statement:

          Public ProjectInstaller()
          {
          InitialiseComponent();
          }

          I Added the following:

          public override void Install(IDictionary stateSaver)
          {
          base.Install(stateSaver);
          ServiceController controller = new ServiceCOntroller("//Service Name");
          controller.Start();
          }

          You will also need to add using System.ServiceProcess; at the top of the file. I hope this helps, it took me a while to find the answer searching google. It works a treat for me.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups