Click here to Skip to main content
11,409,138 members (63,336 online)
Click here to Skip to main content

Adding a description to a .NET Windows Service

, 6 Feb 2002
Rate this:
Please Sign up or sign in to vote.
This article describes how to add a description for your .NET Framework Windows Service to the Services administration tool.
<!-- Download Links --> <!-- Article image -->

Sample Image - example.gif

<!-- Add the rest of your HTML here -->


Although the .NET Framework provides extremely robust Windows Service support through the classes available under the System.ServiceProcess namespace, for some reason the ability to specify your the description displayed in the Services control panel applet/MMC snap-in for your service was omitted. There exists an attribute class named ServiceProcessDescription, but it actually specifies what the Services MMC displays under the name column, and the Description column is left blank. This article will walk you through a low-level hack for adding a description by adding it directly to your service's registry key.

Most services keep their configuration information in the registry under the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ key. This is where the Service Control Manager (SCM) looks to get a list of services installed on a machine, and the Services control panel uses the SCM to list and modify the services. If you look under the key for a service, you'll see several entries, but we're interested in one in particular: the Description value. This is a REG_SZ (string) value, and this is where the SCM looks to get a service's description. We'll now take advantage of this arcane knowledge in the code below (you may download the source by clicking here):

//This code should be inserted into your ProjectInstaller class' code

public override void Install(IDictionary stateServer)
  Microsoft.Win32.RegistryKey system,
    //...\<Service Name>
    //...\Parameters - this is where you can put service-specific configuration

    //Let the project installer do its job

    system = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("System");
    //Open CurrentControlSet
    currentControlSet = system.OpenSubKey("CurrentControlSet");
    //Go to the services key
    services = currentControlSet.OpenSubKey("Services");
    //Open the key for your service, and allow writing
    service = services.OpenSubKey(this.serviceInstaller1.ServiceName, true);
    //Add your service's description as a REG_SZ value named "Description"
    service.SetValue("Description", "This is my service's description.");
    //(Optional) Add some custom information your service will use...
    config = service.CreateSubKey("Parameters");
  catch(Exception e)
    Console.WriteLine("An exception was thrown during service installation:\n" + e.ToString());

public override void Uninstall(IDictionary stateServer)
  Microsoft.Win32.RegistryKey system,

    //Drill down to the service key and open it with write permission
    system = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("System");
    currentControlSet = system.OpenSubKey("CurrentControlSet");
    services = currentControlSet.OpenSubKey("Services");
    service = services.OpenSubKey(this.serviceInstaller1.ServiceName, true);
    //Delete any keys you created during installation (or that your service created)
  catch(Exception e)
    Console.WriteLine("Exception encountered while uninstalling service:\n" + e.ToString());
    //Let the project installer do its job

After you add the above code to your ProjectInstaller class, you should see a description for your service alongside your service's name after your service is installed. In a future article, we'll look at how we can add the description as a custom attribute and extend the ServiceInstaller class to add the description for us automatically.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Andy Hopper
Web Developer
United States United States
Andy Hopper is a Enterprise Architect for Wintellect (, a company that supplies software training, consulting, and debugging services.

Classically trained as an electrical engineer, Andy rediscovered his long-lost love with programming while working on a PhD project and changed careers in 1995 to become a self-taught software engineer. Andy realized his time with C++, VB and ATL were at an end when he received the .NET Framework preview at the 2000 Professional Developer's Conference.

Comments and Discussions

QuestionThanks PinmemberMember 1012372212-Mar-15 1:51 
Questionit is better to use API PinmemberRadu Laurentiu Ialovoi26-Feb-14 23:40 
QuestionVery Nice! This worked for me. PinmemberMember 251592129-Jul-13 4:20 
GeneralMy vote of 5 PinmemberVasileI27-Jul-10 17:07 
Generalgood article for its time PinmemberDonsw29-Nov-09 10:32 
GeneralThere is still a far easier way even in .Net1.1 ... PinmemberMember 307368920-Oct-08 3:46 
NewsThere is a far easier way PinmemberXarium3-May-07 17:06 
GeneralRe: There is a far easier way Pinmemberbkavanaugh1-Jun-07 3:15 2.0 Pinmemberluc_arne9-Oct-06 5:04 
GeneralNice Article Pinmemberkrishna199-Jun-06 1:50 
GeneralA Cleaner Approach in C# Pinmemberc.sharpener6-Feb-06 10:25 
GeneralRe: A Cleaner Approach in C# PinmemberDuoc BT15-Feb-06 18:10 
GeneralRegistry Editor Pinmemberye win zaw29-Sep-05 17:50 
GeneralOffical way to add a description to a service Pinmembernapalm2k10-Sep-05 11:26 
GeneralVery good! PinmemberCaio Proiete28-May-05 10:06 
GeneralReusable component (VB.NET) PinmemberScott Hutchinson12-May-05 16:26 
GeneralRe: Reusable component (VB.NET &amp; C#) PinmemberCaio Proiete28-May-05 10:13 
GeneralVB.Net Translation Pinmemberjbaggaley23-Aug-04 2:15 
GeneralRe: VB.Net Translation PinsussAnonymous7-Oct-05 6:56 
GeneralUser privileges to stop service PinsussAnonymous28-Apr-04 6:17 
GeneralRunnig Winzip from Windows Service PinsussAdeel Ahmad12-Apr-04 2:23 
Generalmultiple services PinsussPer Søderlind16-Mar-04 5:55 
1st. excellent article, you got my 5 Smile | :)

Do you know if Install() is called once or is it called for every Installer.Add() ?

Reason I ask is that I have an application that loads more than one service and would like to set the description for each service dynamicly

public MyInstaller() // Constructor
    ServiceProcessInstaller process = new ServiceProcessInstaller();
    process.Account = ServiceAccount.LocalSystem;
    service1 = new svcInstaller();
    service1.StartType = ServiceStartMode.Manual;
    service1.ServiceName = "Svc1";
    service1.DisplayName = "1st service";
    service1.Description = "This is my first service";
    service2 = new svcInstaller();
    service2.StartType = ServiceStartMode.Manual;
    service2.ServiceName = "Svc2";
    service2.DisplayName = "2nd service";
    service2.Description = "This is my second service";
internal class svcInstaller : ServiceInstaller 
    public string Description;
privat svcInstaller service1,service2;
public override void Install(IDictionary stateServer)
    Microsoft.Win32.RegistryKey system,currentControlSet,services,service

GeneralKey Flushing is required PinmemberpcsInfo9-Mar-04 8:21 
GeneralG&#233;nial PinsussAnonymous1-Dec-03 14:05 
Generaldefault Start Parameters PinmemberBill DeWeese6-Nov-03 15:52 
GeneralCOM .NET Marshaling Pinmemberash8822-Oct-03 22:00 
GeneralRe: COM .NET Marshaling PinmemberPriyacb6-Jul-04 2:49 
GeneralProblems writing registry key PinsussMichael Gamauf5-Sep-03 2:52 
Generalrunning a exe file from windows service Pinmembergoodnews12327-Aug-03 23:55 
GeneralRe: running a exe file from windows service PinmemberOkeno Palmer29-Aug-03 7:57 
Questionwhy so many levels? Pinmemberav41230-Jul-03 12:33 
AnswerRe: why so many levels? Pinmemberthe_cRaCk_6-Aug-03 23:21 
GeneralRe: why so many levels? PinmemberAndy Hopper7-Aug-03 2:24 
GeneralRe: why so many levels? PinmemberRGabo19-Nov-04 18:27 
AnswerRe: why so many levels? Pinmemberakosows8-Jul-05 0:39 
GeneralExcellent Pinmemberzzzzip16-Jun-03 20:27 
QuestionWhat is Windows Service? PinsussAnonymous21-Apr-03 21:33 
AnswerRe: What is Windows Service? Pinmemberxrenvam22-Apr-03 16:12 
Generalthrows exception Pinmemberxrenvam14-Apr-03 15:41 
GeneralAdd Start Parameters to Windows Service PinmemberDavid Spectorman14-Apr-03 4:49 
GeneralRe: Add Start Parameters to Windows Service Pinmemberbooze4-Jul-03 9:46 
GeneralRe: Add Start Parameters to Windows Service PinmemberDavid Spectorman26-Nov-03 2:11 
GeneralThanks! Pinmemberrado20-Feb-03 22:35 
Questionwhat about.... PinmemberFiguerres20-Jan-03 8:24 
AnswerRe: what about.... PinmemberFiguerres21-Jan-03 6:29 
GeneralNiiice Pinmemberkeno8-Jan-03 17:17 
GeneralDescriptions to .NET Services Pinmembervbscripteater26-Aug-02 9:03 
GeneralRe: Descriptions to .NET Services PinsussAnonymous26-Aug-02 17:06 
GeneralRe: Descriptions to .NET Services PinsussAnonymous18-Dec-02 18:33 
GeneralRe: Descriptions to .NET Services PinmemberJim Rogers28-Nov-03 5:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150414.5 | Last Updated 7 Feb 2002
Article Copyright 2002 by Andy Hopper
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid