Hi Anders,
Here is the piece of code that displays the services in the machine and also
there status.
Here in this code i am building a temp DataTable which inserting those
values into it.
so that it can be bind to Datagrid for display purpose.
using System.ServiceProcess;
DataTable dtSrvName = new DataTable();
dtSrvName.Columns.Add(new
DataColumn("ServiceName",Type.GetType("System.Stri ng")));
dtSrvName.Columns.Add(new
DataColumn("ServiceType",Type.GetType("System.Stri ng")));
dtSrvName.Columns.Add(new
DataColumn("Status",Type.GetType("System.String")) );
System.ServiceProcess.ServiceController[] arrSrvCtrl;
arrSrvCtrl = System.ServiceProcess.ServiceController.GetService s();
foreach(System.ServiceProcess.ServiceController tmpSC in arrSrvCtrl)
{
DataRow drSrvName = dtSrvName.NewRow();
if(tmpSC.Status==ServiceControllerStatus.Running )
{
drSrvName[0] = tmpSC.DisplayName.ToString();
drSrvName[1] = tmpSC.ServiceType.ToString();
drSrvName[2] = tmpSC.Status.ToString();
}
else if(tmpSC.Status== ServiceControllerStatus.Paused )
{
drSrvName[0] = tmpSC.DisplayName.ToString();
drSrvName[1] = tmpSC.ServiceType.ToString();
drSrvName[2] = tmpSC.Status.ToString();
}
else
{
drSrvName[0] = tmpSC.DisplayName.ToString();
drSrvName[1] = tmpSC.ServiceType.ToString();
drSrvName[2] = tmpSC.Status.ToString();
}
dtSrvName.Rows.Add(drSrvName);
}
DataGrid1.Visible = true;
DataGrid1.DataSource = dtSrvName;
DataGrid1.DataBind();
lblStatus.Text = "";
Label1.Text = "";
Hope this helps you.
Thanks
Raghavendra
"AndersBj" <An******@discussions.microsoft.com> wrote in message
news:87**********************************@microsof t.com...
Is there a way to monitor a windows service using asp.net? I would like to
have a web page listing 5-6 services and their status (running, stopped
etc). Any tips on how to do this would be appreciated.