WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Terminal Server

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Way to Tell if a Computer is a Terminal Server Remotely

Keywords: 	 terminal server remote

Question:

Is there a way to tell if a computer is a terminal server remotely. Here is my situation. I am running a program that gets a computer name and user name from a txt file. It then goes out and updates the registry of computer. Is there a way to tell remotely if the computer is a terminal server so I can exclude them. As a second option I could exclude ALL servers, is there a way to tell remotely if they are?

Answer:

That's kind of tough to tell. Win2K [and newer] support terminal services in at least a minimal manner to allow you to perform a remote administration connection to a system. There is really no difference in the functionality of remote administration and full blown application terminal services except for the licensing & the # of sessions that are supported. Since this can happen on both pro versions as well as server versions of Win2K/WinXP, I'm not sure exactly how to go about performing a 100% reliable test for terminal services on a remote system.

For starters, you could attempt to establish a TCP connection to the TCP port typically used for accepting RDP [Remote Desktop Protocol] connections. If Citrix is involved then you could also perform the same test using the TCP port commonly used for ICA protocol connections. Failing to connect to the port indicates that no terminal services of any sort are active [or they are listening on TCP ports other than the ones that you are testing for]. Successfully making the TCP connection indicates that a service [presumably the terminal services service] are active on that TCP port. You would use the WinSock extender to do this testing.

Another option is to examine the actual services running on the remote system. If you find a service related to terminal services present and running then you know that terminal services are active on the system. Use the wntSvcStatus() function to test for whether or not a service exists on any particular system. You use the Win32 Network [NT] extender to do this. The service's display name on WinNT v4.0 Terminal Server Edition is "Terminal Server". On Win2K it is "Terminal Services". I don't have WinXP system booted up right at the moment to see if the service's display name changed again in that version of Windows. There are additional services that Citrix Winframe and Metaframe install on top of their base Windows operating systems. If Citrix is in your environment then you would also need to check for those services as well.

If you actually dig around in the registry of the remote system you can determine whether the terminal server service has been configured to use terminal server licensing. If it has been configured to use licensing then it is set up in application terminal services mode and is definitely running as a terminal server. If it has not been configured to use licensing then it is running in remote administration terminal services mode and is not really a true application terminal server system.

I think that a combination of detecting services & interrogating the registry, or just doing it all through the registry, is the best way to go with this. It will be the most reliable method that you can use.


Another User Suggested the Following:

use a CMD and write the ERRORLEVEL or similar into a temp-file:
:start
pslist.exe \\remote-node | find.exe /i "termsrv"
if errorlevel 1 goto not_found
;;; s:\util32\sleep 10
goto start
:not_found
find is part of the OS, pslist is free from www.sysinternals.com

Further updates:

List actual server systems the have terminal services enabled:
list = wntServerList("\\PDC","DOMAIN",33554432)
AskItemList("list of Terminal Servers",list,@tab,@sorted,@single)
exit

Article ID:   W15217
File Created: 2004:01:20:14:45:22
Last Updated: 2004:01:20:14:45:22