Yikes!

When I first presented my example a long time back, it was suggested to convert it to a UDF.. Kind of pointless, I said, because it's just ONE LINE. My example returns the following:
"CON" - a login at the workstation (or server) console
"RDP" - a login using RDP protocol
"ICA" - a login using Citrix ICA protocol

So - if you want to run a command only on the console login (not RDS or ICA), you do the following:
 Code:
$ConnType = Left(%SESSIONNAME%, 3)
If $ConnType = "CON"
  ; do stuff...
EndIf
This compares a specific login type with the type detected. Very straightforward. In this case, the UDF is not only excessive, it complicates matters by changing a single 3-char ID into a text string that, while being human readable, doesn't make the logic any easier.

Let's look at a different example - you want to run only if on an RDS or ICA remote terminal session but not a workstation login:
 Code:
$ConnType = Left(%SESSIONNAME%, 3)
If InStr('ICARDP', $ConnType)
  ; do stuff...
EndIf
This compares the type detected with two or more possible matches, in this case ICA and RDP.

Just replace the "Do stuff..." line with your code.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D