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
  1. Home
  2. General Programming
  3. C#
  4. StartupMode for Services

StartupMode for Services

Scheduled Pinned Locked Moved C#
csharpquestion
7 Posts 3 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.
  • V Offline
    V Offline
    Vijjuuu
    wrote on last edited by
    #1

    Hi All, How can i change the startup mode for services that are already installed in machine using C# code. i tried using ServiceController class in C# but i was not able to find any method to change the start up method for services that are already installed. Thanks in advance

    A C 2 Replies Last reply
    0
    • V Vijjuuu

      Hi All, How can i change the startup mode for services that are already installed in machine using C# code. i tried using ServiceController class in C# but i was not able to find any method to change the start up method for services that are already installed. Thanks in advance

      A Offline
      A Offline
      Abhijit Jana
      wrote on last edited by
      #2

      Vijjuuuuuuuuu........... wrote:

      How can i change the startup mode for services that are already installed in machine using C# code.

      If this is already running, you can change the startup mode from Service Windows [ Run > Services.msc ]. If you want to change it in you code, You have to change the StartUp Type of of your Service Installer.

             serviceInstaller1.StartType = System.ServiceProcess.ServiceStartMode.Automatic;
      

      Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

      V 1 Reply Last reply
      0
      • A Abhijit Jana

        Vijjuuuuuuuuu........... wrote:

        How can i change the startup mode for services that are already installed in machine using C# code.

        If this is already running, you can change the startup mode from Service Windows [ Run > Services.msc ]. If you want to change it in you code, You have to change the StartUp Type of of your Service Installer.

               serviceInstaller1.StartType = System.ServiceProcess.ServiceStartMode.Automatic;
        

        Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

        V Offline
        V Offline
        Vijjuuu
        wrote on last edited by
        #3

        Thanks for reply but the code that you provided is when we are installing the own service . My need is i want to change the already installed services , for example windows services are installed with default value . i want to change them .. hope you got my question

        A 1 Reply Last reply
        0
        • V Vijjuuu

          Thanks for reply but the code that you provided is when we are installing the own service . My need is i want to change the already installed services , for example windows services are installed with default value . i want to change them .. hope you got my question

          A Offline
          A Offline
          Abhijit Jana
          wrote on last edited by
          #4

          That I have already mentioned to you. Start > Run > Services.msc> Right Click on The Services > Change the Startup Mode. If you have to code, then you need to change and reinstall the service again !

          Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

          1 Reply Last reply
          0
          • V Vijjuuu

            Hi All, How can i change the startup mode for services that are already installed in machine using C# code. i tried using ServiceController class in C# but i was not able to find any method to change the start up method for services that are already installed. Thanks in advance

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

            You could try by changing the Start value in the registry for your service (though I haven't tried this myself, but I figure it would work). HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ServiceName\ Start REG_DWORD (2) <- Change this value to either: 2 = Automatic 3 = Manual 4 = Disabled

            A 1 Reply Last reply
            0
            • C Calla

              You could try by changing the Start value in the registry for your service (though I haven't tried this myself, but I figure it would work). HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ServiceName\ Start REG_DWORD (2) <- Change this value to either: 2 = Automatic 3 = Manual 4 = Disabled

              A Offline
              A Offline
              Abhijit Jana
              wrote on last edited by
              #6

              Would it be any problem if we change it from Service Console ?

              Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

              C 1 Reply Last reply
              0
              • A Abhijit Jana

                Would it be any problem if we change it from Service Console ?

                Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

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

                I'm not sure I understand what you mean.. What would be a problem?

                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