---
title: "How to show all services in C#"  
description: "In this blog I am trying to make a small demo which is show all running services in C#.In this article I use the ServiceController property and get al"  
author: "Vijay Shukla"  
published: 2013-06-17  
updated: 2014-09-18  
canonical: https://www.mindstick.com/blog/530/how-to-show-all-services-in-c-sharp  
category: "c#"  
tags: ["c#"]  
reading_time: 2 minutes  

---

# How to show all services in C#

In this blog I [am trying](https://answers.mindstick.com/qa/36834/which-two-programming-languages-should-i-master-in-if-i-am-trying-to-get-into-google-or-facebook) to make a small demo which is show all running [services](https://www.mindstick.com/articles/13111/distinctions-of-iiot-services-how-its-helps-brands) in C#.In this [article](https://www.mindstick.com/articles/95867/are-you-looking-for-500-credit-score-mortgage-lenders-houston-continue-reading-this-article) I use the ServiceController [property](https://www.mindstick.com/blog/205/property-notification-in-c-sharp) and get all services use ServiceController.GetServices() method below I am creating a demo [project](https://www.mindstick.com/articles/105927/how-to-excel-at-managing-multiple-projects) which is shows all running [as well as](https://www.mindstick.com/interview/2481/can-you-write-a-java-class-that-could-be-used-both-as-an-applet-as-well-as-an-application) stopped services in a [datagridview](https://www.mindstick.com/articles/607/working-with-datagridview-in-vc-sharp):-

##### Steps for creating demo project:-

1. Create a new project New >> Project (give the appropriate name of project).\
2. Now by default show a form1, in form1 [drag and drop](https://www.mindstick.com/forum/454/how-to-drag-and-drop-multiple-image-from-one-canvas-to-onther-canvas-in-html5) a datagridview where shows all services.\
3. Now [double click](https://www.mindstick.com/forum/155692/what-is-dfp-double-click-for-publisher) on the form1 and get the form load event.\
4. In the form load event write the below code.

```
  private void Form1_Load(object sender, EventArgs e)  {
  foreach (ServiceController service in ServiceController.GetServices())  {
  string serviceName = service.ServiceName;  string serviceType = service.ServiceType.ToString();  string status = service.Status.ToString();  dgvServicesList.Rows.Add(serviceName, serviceType, status);
  }

 }
```

##### Code description:-

##### 1. This is the form load event method.

##### \
3. This is foreach loop, this loop will run while

##### \
ServiceController.GetServices() method return value.

5. This line of code gets the running and stopped [service](https://www.mindstick.com/articles/105963/online-thesis-writing-service-for-college-kids-with-disabilities) name and assign on string serviceName variable.

6. This line of code gets the running and stopped service type and assign on string serviceType variable.

7. This line of code gets the running and stopped status.

8. This line of code set the value in datagridview.

##### Output Screenshot:-

![How to show all services in C#](https://www.mindstick.com/blogs/8a93ae8c-8f81-45c5-b942-bd05464eb014/images/b1388011-3f03-431b-aee5-8e245418f83b.png)

---

Original Source: https://www.mindstick.com/blog/530/how-to-show-all-services-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
