Page 1 of 1 1
Topic Options
#186878 - 2008-04-12 02:01 AM Problem to get Information from client object Properties
donald_99b Offline
Just in Town

Registered: 2008-04-12
Posts: 3
Hello to the Genius on this realy great Board,

I must collect Informations from MS-Terminalserver Session to write to a SQL Database.

I Use the WTSManager.dll. But i get no Results from the WTS.Client Section. I think i had an Problem with an array, is this so?. Here is the Code Fragment:

$WTS = CreateObject("WTSManager.Shell")
$tsclientip = $WTS.MyIPAddress
$tsusername = $WTS.MyUserName
$wkstaname = $WTS.MyClientName
$tsclientcount = $WTS.ClientCount
For $i = 1 to $tsclientcount
? $WTS.Clients($i).UserName
? $WTS.Clients($i).BuildNumber
? $WTS.Clients($i).WinStationName
? $WTS.Clients($i).ScreenColorDepth
Next

When i use the Sample Code with VB-Script it Works, here the VB-Code :

Set WTS = Wscript.CreateObject("WTSManager.Shell")
MsgBox "My computer name: " + WTS.MyClientName + Chr(13) + "My IP address: " + WTS.MyIPAddress
S = "Total sessions: " & WTS.ClientCount
for i = 1 to WTS.ClientCount
S = S + Chr(13) + WTS.Clients(i).WinStationName + " User: " + WTS.Clients(i).UserName + " IP: " + WTS.Clients(i).IPAddress
Next
MsgBox S

So can anyone help me?

Top
#186879 - 2008-04-12 03:44 AM Re: Problem to get Information from client object Properties [Re: donald_99b]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4510
Loc: USA
I'm not sure what you are trying to do, but here is a translation of the vb code you provided

(untested)
$WTS = CreateObject("WTSManager.Shell")
$RC=MessageBox("My computer name: " + $WTS.MyClientName + Chr(13) + "My IP address: " + $WTS.MyIPAddress,"Title")
$S = "Total sessions: " + $WTS.ClientCount
for $i = 1 to $WTS.ClientCount
$S = $S + Chr(13) + $WTS.Clients($i).WinStationName + " User: " + $WTS.Clients($i).UserName + " IP: " + $WTS.Clients($i).IPAddress
Next
$RC=MessageBox($S,"title")


Edited by Allen (2008-04-12 06:03 AM)

Top
#186882 - 2008-04-12 10:50 AM Re: Problem to get Information from client object Properties [Re: Allen]
donald_99b Offline
Just in Town

Registered: 2008-04-12
Posts: 3
Thank you for translation, but the Result was not the same like VB.

The first Script Step Show an Messagebox with Hostname and IP Address, this works.
After klicking the OK Button, on 2. Step no Information was in the Box.

Is here different Way to work with the WTSManager.dll than VB?

Thank for answers.

Top
#186884 - 2008-04-12 04:27 PM Re: Problem to get Information from client object Properties [Re: donald_99b]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4510
Loc: USA
Try this one. In the first translation I missed the parenthesis, "($i)". Again, I can't test this, but $WTS.Clients is probably an array (or similar). In kix when you want to work with an individual element of an array you would use "[$i]" instead.

$WTS = CreateObject("WTSManager.Shell")
$RC=MessageBox("My computer name: " + $WTS.MyClientName + Chr(13) + "My IP address: " + $WTS.MyIPAddress,"Title")
$S = "Total sessions: " + $WTS.ClientCount
for $i = 1 to $WTS.ClientCount
$S = $S + Chr(13) + $WTS.Clients[$i].WinStationName + " User: " + $WTS.Clients[$i].UserName + " IP: " + $WTS.Clients[$i].IPAddress
Next
$RC=MessageBox($S,"title")

Top
#186885 - 2008-04-12 04:51 PM Re: Problem to get Information from client object Properties [Re: Allen]
donald_99b Offline
Just in Town

Registered: 2008-04-12
Posts: 3
Thank you for your Code, but the Result ist the Same. It show no Result for the Client Property.

Have you or any other any Idea ?

Thank you

Top
Page 1 of 1 1


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

Who's Online
2 registered (Allen, Scott_Simmons) and 218 anonymous users online.
Newest Members
dimi575, Drecksnacken, Nlill, webtools321, multiman
17734 Registered Users

Generated in 0.031 seconds in which 0.011 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