Windows NT Total Terminal Server connections

  • Thread starter Thread starter Jeff Volante
  • Start date Start date
J

Jeff Volante

Hi all,

I am trying to find a way to pragmatically determine the total number of
connections for a given terminal server. I know that I can get this
information via the "qwinsta /counter" command, but where is this info
stored. I thought I could get it via WMI and the Win32_TerminalService
class which has a property called TotalCount. When I query this class I get
no information back. Is this information stored in the registry or
somewhere? Any solutions are fine. Thanks.
 
From
http://ts.veranoest.net/ts_faq_administration.htm#TSSessionCount

Q: How can I retrieve the total number of sessions on my Terminal
Server?

A: TS Manager shows you all existing sessions, but doesn't give the
total count.
If you are running Windows 2003 on your TS, you can use the
following script (save it as TSSessionCount.vbs):

Set obji = GetObject("winmgmts:{impersonationLevel=impersonate}!
Win32_Service='TermService'")
wscript.echo "Total sessions: " & obji.TotalSessions
wscript.echo "Disconnected sessions: " & obji.DisconnectedSessions

Run the script from a command prompt with:
cscript TSSessionCount.vbs
_________________________________________________________
Vera Noest
MCSE, CCEA, Microsoft MVP - Terminal Server
TS troubleshooting: http://ts.veranoest.net
___ please respond in newsgroup, NOT by private email ___

"Jeff Volante" <jeff.volante@gmail.com> wrote on 25 aug 2007 in
microsoft.public.windows.terminal_services:

> Hi all,
>
> I am trying to find a way to pragmatically determine the total
> number of connections for a given terminal server. I know that
> I can get this information via the "qwinsta /counter" command,
> but where is this info stored. I thought I could get it via WMI
> and the Win32_TerminalService class which has a property called
> TotalCount. When I query this class I get no information back.
> Is this information stored in the registry or somewhere? Any
> solutions are fine. Thanks.
 
That script only displays active sessions. I am looking for the total
number of sessions since last reboot. That is what "qwinsta /counter"
displays along with other information.


"Vera Noest [MVP]" <vera.noest@remove-this.hem.utfors.se> wrote in message
news:Xns9997CFDDA4330veranoesthemutforsse@207.46.248.16...
> From
> http://ts.veranoest.net/ts_faq_administration.htm#TSSessionCount
>
> Q: How can I retrieve the total number of sessions on my Terminal
> Server?
>
> A: TS Manager shows you all existing sessions, but doesn't give the
> total count.
> If you are running Windows 2003 on your TS, you can use the
> following script (save it as TSSessionCount.vbs):
>
> Set obji = GetObject("winmgmts:{impersonationLevel=impersonate}!
> Win32_Service='TermService'")
> wscript.echo "Total sessions: " & obji.TotalSessions
> wscript.echo "Disconnected sessions: " & obji.DisconnectedSessions
>
> Run the script from a command prompt with:
> cscript TSSessionCount.vbs
> _________________________________________________________
> Vera Noest
> MCSE, CCEA, Microsoft MVP - Terminal Server
> TS troubleshooting: http://ts.veranoest.net
> ___ please respond in newsgroup, NOT by private email ___
>
> "Jeff Volante" <jeff.volante@gmail.com> wrote on 25 aug 2007 in
> microsoft.public.windows.terminal_services:
>
>> Hi all,
>>
>> I am trying to find a way to pragmatically determine the total
>> number of connections for a given terminal server. I know that
>> I can get this information via the "qwinsta /counter" command,
>> but where is this info stored. I thought I could get it via WMI
>> and the Win32_TerminalService class which has a property called
>> TotalCount. When I query this class I get no information back.
>> Is this information stored in the registry or somewhere? Any
>> solutions are fine. Thanks.
 
qwinsta.exe uses the regrettably undocumented winsta.dll. From that
DLL it imports WinStationGetTermSrvCountersValue which is probably the
function you are looking for. You will have to experiment a little to
get the parameters right - I did a quick internet search and found
nothing helpful.

By the way: I found this out with depends.exe.

I hope this helps.

Helge

On 25 Aug., 21:12, "tom" <tjackson...@hotmail.com> wrote:
> That script only displays active sessions. I am looking for the total
> number of sessions since last reboot. That is what "qwinsta /counter"
> displays along with other information.
>
> "Vera Noest [MVP]" <vera.no...@remove-this.hem.utfors.se> wrote in messagenews:Xns9997CFDDA4330veranoesthemutforsse@207.46.248.16...
>
> > From
> >http://ts.veranoest.net/ts_faq_administration.htm#TSSessionCount

>
> > Q: How can I retrieve the total number of sessions on my Terminal
> > Server?

>
> > A: TS Manager shows you all existing sessions, but doesn't give the
> > total count.
> > If you are running Windows 2003 on your TS, you can use the
> > following script (save it as TSSessionCount.vbs):

>
> > Set obji = GetObject("winmgmts:{impersonationLevel=impersonate}!
> > Win32_Service='TermService'")
> > wscript.echo "Total sessions: " & obji.TotalSessions
> > wscript.echo "Disconnected sessions: " & obji.DisconnectedSessions

>
> > Run the script from a command prompt with:
> > cscript TSSessionCount.vbs
> > _________________________________________________________
> > Vera Noest
> > MCSE, CCEA, Microsoft MVP - Terminal Server
> > TS troubleshooting: http://ts.veranoest.net
> > ___ please respond in newsgroup, NOT by private email ___

>
> > "Jeff Volante" <jeff.vola...@gmail.com> wrote on 25 aug 2007 in
> > microsoft.public.windows.terminal_services:

>
> >> Hi all,

>
> >> I am trying to find a way to pragmatically determine the total
> >> number of connections for a given terminal server. I know that
> >> I can get this information via the "qwinsta /counter" command,
> >> but where is this info stored. I thought I could get it via WMI
> >> and the Win32_TerminalService class which has a property called
> >> TotalCount. When I query this class I get no information back.
> >> Is this information stored in the registry or somewhere? Any
> >> solutions are fine. Thanks.
 
Back
Top