Get Windows service dependencies using C# -


i can use powershell easily, looking c# way this. ps, can use get-service iterate on collection , check collections in there called dependentservices , requiredservices list of dependent , required services given service.

i've looked wmi model using query "select * win32_service", returns collection of win32_service objects not seem have collections interested in. feel missing here. have looked around , tried various searches, i've not turned c#-centric way of doing this.

i want query given service , collections mentioned above (dependentservices , requiredservices). sorry if missed obvious, have not been able find relevant topics.

you can use servicecontroller class:

stringbuilder sb = new system.text.stringbuilder(); foreach (var svc in system.serviceprocess.servicecontroller.getservices()) {     sb.appendline("============================");     sb.appendline(svc.displayname);     foreach (var dep in svc.dependentservices)     {         sb.appendformat("\t{0}", dep.displayname);         sb.appendline();     } }  messagebox.show(sb.tostring()); 

Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -