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

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -