Share this page 

Detect if user is using Terminal ServerTag(s): WinAPI/Registry


[external function declaration]
FUNCTION Integer GetSystemMetrics (Integer nIndex) LIBRARY "user32.dll"


[powerscript]
integer SM_REMOTESESSION = 4096  // remote session
integer SM_REMOTECONTROL = 8193  // remote control

IF GetSystemMetrics(SM_REMOTESESSION)> 0 THEN
    // on terminal server
END IF
Another way is to check the Windows environment variable sessionname. The value of this environment variable will be 'Console' for a normal, local session. For an Remote Desktop session it will contain the phrase 'RDP'.
ContextKeyword lcxk_base
string ls_Path
string ls_values[]

this.GetContextService("Keyword", lcxk_base)
lcxk_base.GetContextKeywords("sessionname", ls_values)

MessageBox("", ls_values[1])