I know I can use wntSvcCfgGet to determine a service's dependencies. How can I determine its dependents?
You could spin through all the services checking for your service of interest among each services dependencies. Or you could execute the the 'sc enumdepend service-name-here' command using a cmd.exe instance and collect the output via one of several techniques available to WinBatch scripts and parse the output. Or you could spin through the registry checking each service's 'DependOnService' value for the name of your service of interest. Or you could use CLR hosting:
ObjectClrOption('use',"System.ServiceProcess, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
objController = ObjectClrNew("System.ServiceProcess.ServiceController", "spooler") ; Spooler service as an example
aDependents = objController.DependentServices
strNames = ''
foreach objService in aDependents
strNames := objService.DisplayName:@LF
objService.Dispose()
next
objController.Dispose()
Message("Dependent Services", strNames)
I am sure there are other approaches as well.
That works great. I'm especially pleased because I failed to mention in my original post that I can't use WMI - I'm working on something for systems with corrupted WMI repositories.
I'm fascinated by the concatenation you're using with the := I've used colons for concatenation, but for something like this, I've always used an ItemInsert or strNames = strNames : new text.