November 30, 200520 yr Does anyone know if its possible to obtain the Client Name (that is, the host name) of a user connected to a terminal server remotely (with a script or command line tool)? You can obtain this information graphically from the Terminal Services Manager snap-in (see screenshot).The Query User command (or QWINSTA) only returns the Session Name.Alternatively, remotely reading the user's %CLIENTNAME% environment variable would work as well.
December 1, 200520 yr Author Unfortunately, no.The closest thing it gives to client name is session name (RDP-TCP#xx), but I need the actual host name that the client is connected from.
December 1, 200520 yr You'll probably have to check out the WTS API's on MSDN, then, as that's the only other way I know of getting info from a TS machine.http://www.microsoft.com/msj/1099/terminal/terminal.aspx
December 1, 200520 yr Author I've tried using those (WTSManager.dll) in a vbs script, and the script works when run from the terminal server itself. But I can't find a way to get the script to work remotely from another computer.Looking through the article I noticed it mentions using "WTSOpenServer( LPTSTR pServerName)" to connect to a different server, but I haven't had luck getting it to work yet.
Create an account or sign in to comment