Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

Get status of Window service installed on your machine using System.ServiceProcess in C# .NET 2.0

Author: Zunnair
Download Source Code : 723_GetStatusWindowService.zip

: In this simple article you will learn that how you can get status of Window service installed on your machine using System.ServiceProcess Namespace.

Simply just create New Project of windows application in C#.

 

Import ServiceProcess APIs

 

using System. ServiceProcess;

 

Drag two labels, one button and one text box on the form.

 

Now write following code on form Load event

private void Form1_Load(object sender, EventArgs e)

        {

            this.Text = "DevAsp Get Service Status";

            label3.Text = "";

            textBox1.Text = "ASP.NET State Service";

        }

 

Now write code on buttons events

 

private void button1_Click(object sender, EventArgs e)

        {

            if (textBox1.Text != "")

            {

                try

                {

                    ServiceController srvs = new ServiceController(textBox1.Text);

                    label3.Text = srvs.Status.ToString();

                }

                catch (Exception ex)

                {

                    MessageBox.Show(ex.Message);

                }

            }

            else

                MessageBox.Show("Enter Value");

        }

 

On button1_Click function u will get status of Window service.

Here srvs.status function return status of the service.

 

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< Get All Window services installed on your machine using System.ServiceProcess in C# .NET 2.0.

Disclaimer - Privacy
© 2002-2017 DevASP.net