I am I running from a RDP or WTS session

Started by Jeremy Whilde, February 18, 2015, 06:29:20 AM

Previous topic - Next topic

Jeremy Whilde

For a compiled WB script I need to check if I am running in a RDP session or a WTS session so that I can react appropriately. By this I mean the compiled script will be installed on both a Win 7 PC which users remote into using RDP and also on a WTS (server) where users connect to on site, but also it may be run on individual none WTS or RDP sessions on Win 7 PC's in a none WTS or RDP environment.

OK I can use Environment("SESSIONNAME" )

This is OK for telling me that I am running on an RDP session as it returns "RDP#"
but it seems to return "Console" on any Win 7 PC and also on a WTS (Server) machine
So how do you tell when the compiled script is being run on a PC connected to a WTS server?

Same with the extender and using wtsIsTSEnabled() this returns 1 for win 7 pcs and a WTS (server)

Any ideas?

Thanks JW


td

Terminal services are enabled on any modern versions of Windows that allows fast user switching.  You could try using the  wtsGetActiveConsoleSessId to get the current console session id and compare it to the session id of the script.  The example at the bottom of the wtsProcIdToSessId function's documentation shows how to get the session id of the current script's process.

If the script is not running as the console session then it will not have the console session ID and hopefully be a remote session or a dumb terminal session.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade