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. how to add new windows service by using C# code

how to add new windows service by using C# code

Scheduled Pinned Locked Moved C#
csharptutorial
9 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.
  • W Offline
    W Offline
    wasimsharp
    wrote on last edited by
    #1

    Can any body tell me how to add new windows service

    wasim khan

    P T 2 Replies Last reply
    0
    • W wasimsharp

      Can any body tell me how to add new windows service

      wasim khan

      P Offline
      P Offline
      Parwej Ahamad
      wrote on last edited by
      #2

      You mean to say, how to install a window service or you want to create a service?

      Parwej Ahamad R & D with IIS 5.0/6.0

      W 1 Reply Last reply
      0
      • P Parwej Ahamad

        You mean to say, how to install a window service or you want to create a service?

        Parwej Ahamad R & D with IIS 5.0/6.0

        W Offline
        W Offline
        wasimsharp
        wrote on last edited by
        #3

        hi i have a service that is created by my friend in VB and now i want to add it my Computer Services by C# code how will i do this

        wasim khan

        M 1 Reply Last reply
        0
        • W wasimsharp

          hi i have a service that is created by my friend in VB and now i want to add it my Computer Services by C# code how will i do this

          wasim khan

          M Offline
          M Offline
          mav northwind
          wrote on last edited by
          #4

          You can use the ServiceInstaller class. It's part of the BCL.

          Regards, mav -- Black holes are the places where God divided by 0...

          1 Reply Last reply
          0
          • W wasimsharp

            Can any body tell me how to add new windows service

            wasim khan

            T Offline
            T Offline
            telha
            wrote on last edited by
            #5

            Well there are certain ways to add a service to your windows registered services. 1) You can use the InstallUtil tool that comes with the .Net Framework;Go to the Visual Studio Command prompt and there type InstallUtil Path-to-Assembly-to-be-installed-as-service This is a manual procedure. 2) Create a new setup project using the Visual Studio Setup Wizard and then under the "File System Editor" add the output (the assembly that you want to install as service", after this go to "Custom Actions Editor", you will see four folders there, 1- Install, 2- Commit, 3- Rollback and 4- Uninstall, right click on Install and click on "Add Custom Action" from the resulting menu, under the result dialog, locate the application folder and locate the assembly of the service that you just added in Application Folder, double click on this assembly. Now when you run the setup project, the service will be added to your windows services if everything goes well. For both the procedures, you would need to go to windows services console and start the service manually.

            Muhammad Talha

            W 2 Replies Last reply
            0
            • T telha

              Well there are certain ways to add a service to your windows registered services. 1) You can use the InstallUtil tool that comes with the .Net Framework;Go to the Visual Studio Command prompt and there type InstallUtil Path-to-Assembly-to-be-installed-as-service This is a manual procedure. 2) Create a new setup project using the Visual Studio Setup Wizard and then under the "File System Editor" add the output (the assembly that you want to install as service", after this go to "Custom Actions Editor", you will see four folders there, 1- Install, 2- Commit, 3- Rollback and 4- Uninstall, right click on Install and click on "Add Custom Action" from the resulting menu, under the result dialog, locate the application folder and locate the assembly of the service that you just added in Application Folder, double click on this assembly. Now when you run the setup project, the service will be added to your windows services if everything goes well. For both the procedures, you would need to go to windows services console and start the service manually.

              Muhammad Talha

              W Offline
              W Offline
              wasimsharp
              wrote on last edited by
              #6

              thanx for ur breif Answere i think that will help me

              wasim khan

              1 Reply Last reply
              0
              • T telha

                Well there are certain ways to add a service to your windows registered services. 1) You can use the InstallUtil tool that comes with the .Net Framework;Go to the Visual Studio Command prompt and there type InstallUtil Path-to-Assembly-to-be-installed-as-service This is a manual procedure. 2) Create a new setup project using the Visual Studio Setup Wizard and then under the "File System Editor" add the output (the assembly that you want to install as service", after this go to "Custom Actions Editor", you will see four folders there, 1- Install, 2- Commit, 3- Rollback and 4- Uninstall, right click on Install and click on "Add Custom Action" from the resulting menu, under the result dialog, locate the application folder and locate the assembly of the service that you just added in Application Folder, double click on this assembly. Now when you run the setup project, the service will be added to your windows services if everything goes well. For both the procedures, you would need to go to windows services console and start the service manually.

                Muhammad Talha

                W Offline
                W Offline
                wasimsharp
                wrote on last edited by
                #7

                Talha can u tell me about how can i add service using C# code and thnax for ur first replay it really work

                wasim khan

                T 1 Reply Last reply
                0
                • W wasimsharp

                  Talha can u tell me about how can i add service using C# code and thnax for ur first replay it really work

                  wasim khan

                  T Offline
                  T Offline
                  telha
                  wrote on last edited by
                  #8

                  Well I also looked a sample on Code Project for this which calls the InstallUtil utility through code, I guess if you search this site for Dynamic Windows Service Installer, you will come across that.... anyway the code is as: using System; using System.Diagnostics; using System.Net; using System.IO; namespace ServiceInstaller { /// /// /// public enum WindowsServiceAccountType { LocalService, NetworkService, LocalSystem, User } /// /// /// public class WindowsServiceInstallInfo { #region "FIELDS" private System.String _windowsServiceName; private System.String _wsDescription; private readonly string _windowsServicePath; private readonly string _windowsServiceAssemblyName; private WindowsServiceAccountType _wsAccountType; private readonly string _wsAccountUserName; private readonly string _wsAccountPassword; #endregion #region "CONSTRUCTOR" /// /// /// /// Path to folder where Windows Service binary is located. /// Windows Service Assembly Name. /// Windows Service Account Type.(not user type) public WindowsServiceInstallInfo(string windowsServicePath, string windowsServiceAssemblyName, WindowsServiceAccountType wsAccountType) : this("", windowsServicePath, windowsServiceAssemblyName, wsAccountType) { } /// /// /// /// Name of the windows service. /// Path to folder where windows service assembly stored. /// windows service assembly name. /// Windows service account type (not user type) public WindowsServiceInstallInfo(string windowsServiceName, string windowsServicePath, string windowsServiceAssemblyName, WindowsServiceAccountType wsAccountType) : this(windowsServiceName, "", windowsServicePath, windowsServiceAssemblyName, wsAccountType) { } /// /// /// /// Name of windows service.

                  W 1 Reply Last reply
                  0
                  • T telha

                    Well I also looked a sample on Code Project for this which calls the InstallUtil utility through code, I guess if you search this site for Dynamic Windows Service Installer, you will come across that.... anyway the code is as: using System; using System.Diagnostics; using System.Net; using System.IO; namespace ServiceInstaller { /// /// /// public enum WindowsServiceAccountType { LocalService, NetworkService, LocalSystem, User } /// /// /// public class WindowsServiceInstallInfo { #region "FIELDS" private System.String _windowsServiceName; private System.String _wsDescription; private readonly string _windowsServicePath; private readonly string _windowsServiceAssemblyName; private WindowsServiceAccountType _wsAccountType; private readonly string _wsAccountUserName; private readonly string _wsAccountPassword; #endregion #region "CONSTRUCTOR" /// /// /// /// Path to folder where Windows Service binary is located. /// Windows Service Assembly Name. /// Windows Service Account Type.(not user type) public WindowsServiceInstallInfo(string windowsServicePath, string windowsServiceAssemblyName, WindowsServiceAccountType wsAccountType) : this("", windowsServicePath, windowsServiceAssemblyName, wsAccountType) { } /// /// /// /// Name of the windows service. /// Path to folder where windows service assembly stored. /// windows service assembly name. /// Windows service account type (not user type) public WindowsServiceInstallInfo(string windowsServiceName, string windowsServicePath, string windowsServiceAssemblyName, WindowsServiceAccountType wsAccountType) : this(windowsServiceName, "", windowsServicePath, windowsServiceAssemblyName, wsAccountType) { } /// /// /// /// Name of windows service.

                    W Offline
                    W Offline
                    wasimsharp
                    wrote on last edited by
                    #9

                    thnax Talha i think that is enough for me :|

                    wasim khan

                    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