Here’s the background: In Windows 2012 (in workgroup mode) the only way to shadow a user's RDP session is via command line, which is really annoying.
So I wanted to build a small utility around the command line that would be more user friendly.
I wrote “shadow.bat” that eases the pain a little. It accepts one parameter. That parameter is the user who you want to shadow.
i.e. If I log on to a 2012 server and want to see what user BOB is doing, I need to run/type: shadow BOB
My code for "shadow.bat" is simple:
for /F "tokens=3 skip=1" %%i in ('query user %1') DO (
mstsc.exe /shadow:%%i /noConsentPrompt /control
The incoming %1 parameter is the username I want to shadow. It obtains the session number of the user from there (%%I) and runs mstsc.exe with a shadow switch. I'm good to go.
What I really want to do is take away the need to run this .bat manually from command line.
How difficult would it be to have my code inside a compiled .exe where upon running, the program presents you with a dropdown list of logged on users, and you pick who you want to shadow ?
So I’d run “shadow.exe” and it would show a list of users logged on to my server, I'd pick a user to shadow, and it basically takes that username and puts it into the %1 variable in my bat script.
I'm good at .bat, vbscript, VB6.0....but .NET not really. This is a little beyond my area of expertise. does anybody have code suggestions? maybe something I can copy & paste then compile?