All Things WinBatch > WinBatch

Determine RDP Session on Windows 7

(1/3) > >>

Is there a way to identify if an RDP session is connected to a Windows 7 computer?  The wtsEnumSessions command works when I check a server but get "106: Windows Terminal Server Extender: Unable to enumerate sessions" when I point it to a Windows 7 computer.


Assuming you are attempting to check remote sessions remotely, I not aware of any way to make that work when the remote system is Windows 7.  You might be able to do it if the Windows 7 system is part of a Windows network and you connect to the that system from a domain account with "Query Information" privileges on the Windows 7 system.   In the past , I know I have tried using the wntAddDrive with an administrative share trick to connect to a remote Windows 7 system as an administrator of that system before performing a sessions query with not success. 

There are many ways to perform the task locally using the WWWTS44I.DLL extender, using WMI objects, or the "query session" command line utility.  None of them appear to work when targeting a remote Windows 7 system.  I guess the trick would be to figure out how to set the required privileges on Windows 7.

Did a little more checking and discovered that I made an incorrect assumption the last time I attempted to remotely list sessions on a Windows 7 computer.  The assumption was that when terminal services are enabled on a Windows 7 system, RPC is also enabled.   This assumption is false.   It is easy enough to verify by check the list of running services for the RpcSs service.

When RPC is enabled on a Windows 7 system, you can check for remote sessions by using the "query session /server:mywin7compure" where "mywin7computer" sans quotes is the name of Windows 7 computer you want to check.   I was not able to get the information using WMI or the Terminal Services extender - just with the command line "query session" command.  Will need to do some more research to determine why WMI and the extender cannot list sessions.

A few ideas come to mind...

1)  There may be a remote admin RPC service for terminal services that needs to be enabled.

2)  There may be a firewall rule blocking inbound access to the aforementioned RPC service.

3)  There may be a more general "remote admin" setting that needs to be enabled in the "advanced system" properties [which keeps on getting moved around in terms of how you access it] for workstations that is enabled by default for servers.

Thanks for weighing in on this one Chuck. 

The part I don't understand is why the query session command line tool works but the extender does not.  The Windows 7 system has the terminal services AllowRemoteRPC registry setting set to 0x1 and the appropriate firewall ports open.  The fact that "query session" works bares evidence of this.  In fact, "querry session" works when executed from a restricted Windows 10 admin account. 

On the other hand the extender does not work from either a restricted or elevated Windows 10 account.  The system error is consistently 5 so your suggestion that is is account related in some way seems to have merit.  Perhaps it will require some low level investigation of a "query session" process to try and determine what it is up to.


[0] Message Index

[#] Next page

Go to full version