0
Context
So far I've created a shortcut on my desktop with the following command:
%windir%\System32\tscon.exe 1 /dest:console
It was worked like charm with my old Windows 7 machine, where this active rdp session's id was fixed 1. However the same is not true on my new Windows 10 installation, where it is changing.
I found that that command
c:\>qwinsta
can give me the active session's ID, so I can replace the number 1 parameter with that. However it seems to be a productivity bottleneck instead just click on an icon.
Question
Is there any way to solve this one script, to somehow get the current active rdp session ID and call tscon with that?
I would think you could pipe the output from qwinsta to the findstr command looking for "console". the session ID would be 2 tokens from there. poke that into a variable and run your tscon command using the variable instead of the number one. Have you tried this? Is there some reason it cant be done? If you are looking for a 1 liner, that probably can't be done, but your shortcut could call the script... It seems do-able to me. – Larryc – 2019-08-05T19:49:08.417
Thx for the answer, I am gonna try to put this together, although the "poke into a variable" part a bit cloudy for me, but I will google it. – g.pickardou – 2019-08-07T06:29:24.657