I have this Windows Service from my company :
I want to get the service description from it in code behind! but for some reason it does not return the service description.
Can anyone help me with this .
here is my code, and what it returns :
Dim MyServices As ServiceController = New ServiceController("AccTech Exchange Rate Import")
Dim Status As String = MyServices.Status.ToString
Dim Name As String = MyServices.ServiceName
and what the MyService variable returns.
How would i get the Service Description from here?
Regards,
EDIT:
Here is my code after Miki Shah pointed me in the right direction!
Dim MyServices As ServiceController = New ServiceController("AccTech Exchange Rate Import")
Dim Status As String = MyServices.Status.ToString
Dim Name As String = MyServices.ServiceName
Dim Description As String
Dim objPath As String = String.Format("Win32_Service.Name='{0}'", Name)
Using service As New ManagementObject(New ManagementPath(objPath))
Description = service("Description")
End Using
You can get as following way, and have to add reference of System.Management
string serviceName = MyServices.ServiceName
string objPath = string.Format("Win32_Service.Name='{0}'", serviceName);
using (ManagementObject service = new ManagementObject(new ManagementPath(objPath)))
{
Console.WriteLine(service["Description"]);
}