Found the problem.. Using this code to test on my PC
 Code:
Break On

Dim $MaxSess, $TaskList, $aResult, $Message, $Rc, $

$Message ='PROCSS LIMIT EXCEPTION'
$MaxSess = 4

$Tasklist='tasklist /FI "Username eq %USERDOMAIN%\%USERNAME%" /FI "Imagename eq cmd.exe"'
'Running ' $Tasklist ?
$aResult=WshPipe($Tasklist)
UBound($aResult[0]) -1 ' processes' ?
For $ = 0 to UBound($aResult[0])
  $ ' ' $aResult[0][$] ?
Next
;
If UBound($aResult[0]) < ($MaxSess + 1)
  Run '%COMSPEC%'
Else
  $Rc = MessageBox('You are not allowed to run more than two App sessions',$Message,0,10)
EndIf
it returns
 Code:
TECHSERV14 - K:\Misc>limit
Running tasklist /FI "Username eq DOMAIN\userid" /FI "Imagename eq cmd.exe"
4 processes
0
1 Image Name                     PID Session Name        Session#    Mem Usage
2 ========================= ======== ================ =========== ============
3 cmd.exe                       2976 RDP-Tcp#0                  2      4,376 K
4 cmd.exe                       5976 RDP-Tcp#0                  2      5,476 K
5
Clearly there are more lines than the two headers I could "see", so we adjust the test line to
 Code:
If UBound($aResult[0]) < ($MaxSess + 3)
That should do it. When no tasks are present, the header lines fill 4 elements - 0 thru 3. The UBound less 3 returns the number of elements describing the commands found.

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