Page 1 of 1 1
Topic Options
#36484 - 2003-02-14 05:14 AM Detect Terminal Session
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
Does anyone know how to detect if the user is in a Terminal Session or not? Basically I want to know if the user is logged in through console or TS when I process my script.

Thanks
_________________________
Austin Henderson

Top
#36485 - 2003-02-14 05:21 AM Re: Detect Terminal Session
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
the @ProductSuite macro will denote a terminal server and the %sessionname% will denote if logon at the console.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#36486 - 2003-02-14 11:43 AM Re: Detect Terminal Session
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
In a Terminal session @ProductSuite returns Windows 2000 Server (even though it is actually 2000 Advanced Server) and the sessionname returns console as expected in a console logon. @ProductType returns 18 which I dont see in the docs. I can work with the %sessionname% variable and check for the presence of RDP in the string.. thanks for the direction.
_________________________
Austin Henderson

Top
#36487 - 2003-02-14 01:35 PM Re: Detect Terminal Session
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Austin, I think you have @ProductSuite and @ProductType backwards.

If @ProductSuite returns 18 you have to process it like:
code:
Function ProductSuite ($Product)
Dim $Product

select
case $Product = "None" $x=0
case $Product = "Small Business" $x=1
case $Product = "Enterprise" $x=2
case $Product = "BackOffice" $x=4
case $Product = "CommunicationServer" $x=8
case $Product = "Terminal Server" $x=16
case $Product = "Small Business (Restricted)" $x=32
case $Product = "Embedded NT" $x=64
case $Product = "DataCenter" $x=128
case $Product = "Single User Terminal Server" $x=256
case $Product = "Home Edition" $x=512
case $Product = "Blade Server" $x=1024
case 1 $RC=MessageBox ("Invalid parameter used in function ProductSuite ($Product)",48)
WriteLog("Invalid parameter used in function ProductSuite ($Product)")
endselect

$ProductSuite = $x & val(@ProductSuite)
Endfunction

the number requires bitwise processing.

[ 14. February 2003, 13:36: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#36488 - 2003-02-14 03:04 PM Re: Detect Terminal Session
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Austin,
the reason that @ProductSuite returns 18 is that it is a combination of:
case $Product = "Enterprise" $x=2
and
case $Product = "Terminal Server" $x=16

That is the reason for the bitwise operation. On KiX versions prior to 4.2x, @ProductSuite returned a string VarType, hence the Val() in Howard's UDF.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#36489 - 2003-02-14 05:06 PM Re: Detect Terminal Session
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
So moving forward I can expect to return what in future builds for @ProductSuite?

Thanks
_________________________
Austin Henderson

Top
#36490 - 2003-02-14 05:10 PM Re: Detect Terminal Session
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Who can say what the future will bring? Following in logical progression it should be 2048, 4096, 8192, etc.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#36491 - 2003-02-14 05:21 PM Re: Detect Terminal Session
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
Miscommunication there.. sorry my bad. I meant with regard to this...
quote:
On KiX versions prior to 4.2x, @ProductSuite returned a string VarType, hence the Val() in Howard's UDF.

Is this the method as we move forward? Builds of Kix32.exe.

Thanks
_________________________
Austin Henderson

Top
#36492 - 2003-02-14 05:26 PM Re: Detect Terminal Session
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
What do you mean? Of course, KiXtart will be improved continously. Starting with KiXtart 4.20, the @PRODUCTSUITE macro will return a integer value and not a string value.
_________________________
There are two types of vessels, submarines and targets.

Top
#36493 - 2003-02-14 05:39 PM Re: Detect Terminal Session
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
Ohh I know it is being improved.. wasnt asking with any bit of doubt regarding the product just thinking ahead on my script.

Glad to know..

Thanks
_________________________
Austin Henderson

Top
#36494 - 2003-02-14 06:16 PM Re: Detect Terminal Session
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
You can use the VarType() function to determine if your current version is returning a string or number. That way it won't matter when you upgrade.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#36495 - 2003-02-14 06:20 PM Re: Detect Terminal Session
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Austin,
I'm guessing that you are wondering what happens to your code if you use Val() today and then the VarType changes when you go with 4.20.

The easiest way to answer that is to try it out yourself. You should never just take someone's word for it. Better to understand the code.

Cobble together something like the following and test it on the different versions of KiX.

code:
Break on
@KiX ?

;VarType returns:
; 3 Long Integer
; 8 String

$VarType = VarType(@ProductSuite)

Select
Case $VarType = 3
'VarType = '+$VarType+' Long Integer' ?

Case $VarType = 8
'VarType = '+$VarType+' String' ?

Case 1
'VarType = '+$VarType+' None of the above' ?
EndSelect

$ValVarType = VarType(Val(@ProductSuite))

Select
Case $ValVarType = 3
'ValVarType = '+$ValVarType+' Long Integer' ?

Case $ValVarType = 8
'ValVarType = '+$ValVarType+' String' ?

Case 1
'ValVarType = '+$ValVarType+' None of the above' ?
EndSelect

Get $



[ 14. February 2003, 18:25: Message edited by: LLigetfa ]
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#36496 - 2003-02-14 06:27 PM Re: Detect Terminal Session
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
Sure I got you.. wasnt trying to get out of testing just didnt know I could get 4.2 yet.. The latest I se on DL is 4.12.

Thanks for your help guys...

Hey let me pose this question to the board. Without building a timer or something I am wondering if it is quicker to connect to a printer at each logon or check to see if it exists then connect only if it is not needed.. are there any other reasons for one or the other method?

Thanks so much..
_________________________
Austin Henderson

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 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.06 seconds in which 0.029 seconds were spent on a total of 12 queries. Zlib compression enabled.

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