Finding windows services running on another machine under specific user

46 Views Asked by At

I am trying to get the list of windows services that is running on another machine within my network. But I am stuck in finding the list of those service, which run under specific "log on as". Please suggest if you have any idea?

I accomplished the first part using ServiceController class. But the second part I am not able to achieve. Code is pasted below:

public static void GetInstalledServices()
{
    Console.WriteLine("Get list of services...");

    foreach (ServiceController service in ServiceController.GetServices("MyOtherServer021"))
    {
        string serviceName = service.ServiceName;
        string serviceDisplayName = service.DisplayName;
        string serviceType = service.ServiceType.ToString();
        string status = service.Status.ToString();

        //GetLogOnAsForAService(serviceDisplayName);

        Console.WriteLine(serviceName + "---" + serviceDisplayName+ "---" + serviceType + "---" + status);
    }
}

As per abatishchev this question is already answered...But I want the code specific to fetching details from another machine. Please suggest a code for the same.

0

There are 0 best solutions below