How can I programmatically tell if the terminal services service is running and is healthy?
I’m creating a .net console application that will check if terminal services are running on a list of computers.
I can check the remote registry entry to see if it’s enabled, but that doesn’t mean it’s running.
I was thinking of making a socket connection to port 3389, but it doesn’t have to be listening on that port either.
Is there an elegant way to check for this?
Regards,
If you (or, specifically, the user the application runs as) has permission to do so, you could remotely query the SCM of the target machine to determine if the TS service is running.
You should be able to use System.ServiceProcess.ServiceController.GetServices(string machineName) to get a list of all the services on the computer, iterate the result to find the Terminal Services service and query its status.