Page 1 of 1 1
Topic Options
#193612 - 2009-04-28 02:57 PM how can use KIX to detect user logon in terminal
huangwl Offline
Fresh Scripter

Registered: 2009-03-13
Posts: 7
Loc: China
I want to do a judgement that user logon in terminal or console.

Could you help me?

Top
#193613 - 2009-04-28 03:18 PM Re: how can use KIX to detect user logon in terminal [Re: huangwl]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Is this a Microsoft terminal server or a citrix server?

If it is Microsoft then you can get a list of all users on the server if you run the command below from a console window.
It writes all info to tsusers.txt on the d drive but you can change that if needed.

This is not kix code but can easily be converted to kix. The code shown below can be run from a command window.
 Code:
query user >d:\tsusers.txt


The output file looks like this:
 Code:
USERNAME		SESSIONNAME		ID	STATE	IDLE TIME	LOGON TIME
administrator					0	Console		5			02 - Apr-09 13:01
Username1		rdp-tcp#321		43	Active		.			14 - Apr-09 08:36
Username2		rdp-tcp#322		44	Active		1			14 - Apr-09 08:54


You could make a script that process this output and send you the results by e-mail (at least that is what I did).
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#193614 - 2009-04-28 03:44 PM Re: how can use KIX to detect user logon in terminal [Re: huangwl]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
Welcome to KORG!

You can try this:
 Code:
; Determine login type - direct, Terminal Server, or Citrix
; Con=Direct Console, RDP=Terminal Server, or ICA=Citrix
$ConnType = Left(%SESSIONNAME%, 3)

Just use a Select/Case to decide what to do based on the content of $ConnType.

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

Top
#193616 - 2009-04-28 04:38 PM Re: how can use KIX to detect user logon in terminal [Re: Glenn Barnas]
huangwl Offline
Fresh Scripter

Registered: 2009-03-13
Posts: 7
Loc: China
Thanks Glenn to give solution so quickly.

I like KORG!

Top
#193617 - 2009-04-28 04:46 PM Re: how can use KIX to detect user logon in terminal [Re: huangwl]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Glenn's solution will work for the user that runs it. Great way to figure out if the current logon session is a TS session and if needed execute special logon scripts for that.

If you need/want a list of all users on your TS then you'll need a solution like mine or you could use QWINSTA (build in by MS) and walk through the output line by line.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1183 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.103 seconds in which 0.079 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org