The easiest way is to check for variables which are only set in the TS environment.

I use MetaFrame, and I check for WINSTATIONNAME - there are plenty of others.