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:
@echo off
RDPDetect.exe
if ERRORLEVEL 1 goto RDP_ENABLED
if ERRORLEVEL 0 goto RDP_DISABLED
goto END
:RDP_ENABLED
echo This is a RDP Session
goto end
:RDP_DISABLED
echo This is a not a RDP Session
:END
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
{ 7 comments… read them below or add one }
Excellent utility steve. I happen to have the same issue here. I work at a bank that uses software that needs to run at logon to process items through the day. Once in a while someone forgets that they can’t RDP into this system, since it has that same logon script! Then bam, the batch processing crashes and an hour later we get angry calls. With your little tool I can stop this madness once and for all.
I get an error with Windows 2000. Is it supposed to work with it?
No, it won’t work with 2000. This is because it is lacking certain terminal service API calls.
I think it is really rare to see a 2000 TS these days 🙂
Yea, it is an old machine. It is a cisco 4.x call manager server. Not a TS. But since it is 2000 server, it has RDP built in.
Great utility steve. I have run into this issue before. Thanks!
Thanks for the free tool steve. Have a ctrix env here and this is a great little utility!
Hi Steve,
I need a tool that specifies that system info like boot time,free disk space, server name on RDP Session background without logging into server.
Please Can you do that for me?
Thanks in Advance
Naveen.