Ryan asked this week:
“I have a scenario where an application starts when a particular user (generic admin account) logs on to the console. The problem is that when the same user account is also used to login to an RDP session, on the same server, the service tries to start again, and breaks…Is it possible for a logon script to recognize that it is logging on to the console? If so I could start the application from this script and not worry about it starting a second time if someone accidentally RDPs using the same account.”
I originally thought that this could be easily detected by an environment variable, or even VB Script…but it turns out that those two methods are not reliable.
The %SESSIONNAME% variable is set if you are on a terminal server. If you just RDP to the console of a workstation, or server – it is empty.
So instead, we put together a free utility called RDPDetect. It returns 1 if you are in an RDP session, and 0 if you are not. The return value can be picked up as an error level, so you can use it in a bat file like this:
if ERRORLEVEL 1 goto RDP_ENABLED
if ERRORLEVEL 0 goto RDP_DISABLED
echo This is a RDP Session
echo This is a not a RDP Session
You can find it in our download section:
As always, it contains no spyware or adware…only freeware goodness.
It is free for commercial and personal use.
One more thing…Subscribe to my newsletter and get 11 free network administrator tools, plus a 30 page user guide so you can get the most out of them. Click Here to get your free tools