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. NT Service Installation

NT Service Installation

Scheduled Pinned Locked Moved C#
tutorialcsharpquestion
2 Posts 2 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.
  • J Offline
    J Offline
    jparsons
    wrote on last edited by
    #1

    I've read the documentation on how to install an NT service using .NET but I'm unsure of exactly how it works. I 've created the installer object but hte documentation is unclear of what I should do in my Custom Action or even how to set one up properly. Does anyone know of a good tutorial on this? Jared jparsons@jparsons.org www.prism.gatech.edu/~gte477n

    E 1 Reply Last reply
    0
    • J jparsons

      I've read the documentation on how to install an NT service using .NET but I'm unsure of exactly how it works. I 've created the installer object but hte documentation is unclear of what I should do in my Custom Action or even how to set one up properly. Does anyone know of a good tutorial on this? Jared jparsons@jparsons.org www.prism.gatech.edu/~gte477n

      E Offline
      E Offline
      Erik Westermann
      wrote on last edited by
      #2

      I'm actually working on an article that includes coverage of services. Here's the code I use to install a service:

      [RunInstaller(true)] public class ServiceInstaller: Installer
      {
      private System.ServiceProcess.ServiceInstaller svcInst;
      private System.ServiceProcess.ServiceProcessInstaller processInstaller;

      public ServiceInstaller()
      {

      processInstaller = new System.ServiceProcess.ServiceProcessInstaller();
      svcInst = new System.ServiceProcess.ServiceInstaller();
      
      // Service will run under the system account
      processInstaller.Account = ServiceAccount.LocalSystem;
      
      svcInst.StartType = ServiceStartMode.Manual;
      // These are the other possible valuse for ServiceStartMode...
      // ServiceStartMode.Manual
      // ServiceStartMode.Automatic
      // ServiceStartMode.Disabled
      
      
      svcInst.ServiceName = "EWService";
      svcInst.DisplayName="EW Sample Service";
      Installers.Add(svcInst);
      Installers.Add(processInstaller);
      

      }
      }

      The code basically establishes the service's name, display name, startup, and logon. Use InstallUtil to install the service and configure it as in the preceding class. Erik Westermann Author, Learn XML In A Weekend ^ (October 2002)

      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