You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have a use case where we want to connect to a remote windows server and list all of the services on it, along with their running status.
In x/sys/windows/svc/mgr, ListServices() returns all of the services that exist, and then we have to loop through them calling Query() to get the state. This doesn't perform well, so instead, I've got my own custom function in my code which returns the status along with the service name. It looks like this:
It would be good if this functionality was included in the standard mgr package though. It would have to be a new function for backwards compatibility but it could potentially even return the whole ENUM_SERVICE_STATUS_PROCESS struct as an array to expose everything.
The text was updated successfully, but these errors were encountered:
Considering the amount of inputs to EnumServicesStatusEx and the number of properties that it returns (see SERVICE_STATUS_PROCESS), I'm afraid that it makes no sense for windows/svc/mgr to provide specific helpers for each combination of inputs and outputs. For example, why returning the status but not the service type?
You can already get what you want with a few lines of code, and it could be customized further if your requirements change, e.g. you want to filter out some service types.
nit: you could simplify a bit the last part of your code sample by changing it to:
Thanks for the response @qmuntal and for the more readable code.
I agree that it makes no sense to provide helpers for each combination of fields - would you view the proposal more favourably if the suggestion was to keep the existing ListServices function as it is, and just have one more function that returns everything from SERVICE_STATUS_PROCESS? It would be up to the end user which fields they want to use then. The range on "services" should already have access to this data.
We have a use case where we want to connect to a remote windows server and list all of the services on it, along with their running status.
In x/sys/windows/svc/mgr, ListServices() returns all of the services that exist, and then we have to loop through them calling Query() to get the state. This doesn't perform well, so instead, I've got my own custom function in my code which returns the status along with the service name. It looks like this:
It would be good if this functionality was included in the standard mgr package though. It would have to be a new function for backwards compatibility but it could potentially even return the whole ENUM_SERVICE_STATUS_PROCESS struct as an array to expose everything.
The text was updated successfully, but these errors were encountered: