We are currently running RDP on a Windows 2008 server. Some of our users are utilizing generic accounts to access the systems then using a RemoteApp to access our primary software.
The issue we are running into is that our software has some issues and frequently we have to reset the sessions for users. Now i have used the below script for users who are accessing from their own desk / login and it has worked wonderfully. The problem I have is if I cannot query the session by UserName I am unable to return the right Session Name or Session ID. This does not work for users in areas that use generic logins into the computer.
Now I will be the first to state that the shared/generic login is poor practice and needs to go, that is something I am working on but it taking time to get these changes in place.
What I am trying to do is identify the Session Name or Session ID for the current connection from the computer the file is being ran from. I have found a couple of things that look at registry but that has not been working. In layman terms I want to be able to run a bat file that look at my current outbound connection to ServerName and reset it or reset all if there are multiple. Is this possible in any way?
Bat file I am using currently:
echo Current RDP Session ID: %RDP_SESSION%
for /f "tokens=1 delims= " %%G in ('query session %username% /server:ServerName') do SET RDP_SESSION=%%G
reset session %RDP_SESSION% /server:ServerName /v