c# - Read the Description of a Windows Service -
i'm using c:\windows\system32\sc.exe (via system.diagnostics.process
) create several windows services via custom install wizard i've built. each service created contain program 1 or more modules loaded (chosen user via wizard).
when wizard loaded want able inform user of services modules installed. have used service description (sc description "....."
) write modules part of each service.
however, cannot find method read service's description programmatically. find surprising it's not part of system.serviceprocess.servicecontroller
is there way read service's description via c#?
thanks
here 1 way of doing it:
using system; using system.management; public static string getservicedescription(string servicename) { using (managementobject service = new managementobject(new managementpath(string.format("win32_service.name='{0}'", servicename)))) { return service["description"].tostring(); } }
Comments
Post a Comment