Solved

WMI get Client Name(machine name) and Session type from Windows Task Manger

Posted on 2014-03-14
9
1,721 Views
Last Modified: 2014-03-26
How can we get the remote client name & session from the task manager using WMI. We have many servers in our company and need to see who is logged on and the machine name. Using WMI we are able to get the User, ID, and Status from each server.  Everything we have so far works great. These last two items, Client Name and Session or rather Session Type are proving to be a real headache to retrieve. We use VB.Net and Visual Studio 2010 on Windows 7. We would prefer for it to be in managed code but are open to other options except scripting. A VB.Net or C# sample of any kind would be very helpful.
0
Comment
Question by:ypm
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
9 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 39931292
I am not sure that I understand what you mean by "Client Name"...

For session, do you mean Win32_LogonSession?

Win32_LogonSession class
http://msdn.microsoft.com/en-us/library/aa394189(v=vs.85).aspx
0
 

Author Comment

by:ypm
ID: 39934491
XP:
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/taskman_whats_there_w.mspx?mfr=true

Win7:
http://www.techrepublic.com/blog/windows-and-office/reap-the-benefits-of-windows-7s-task-manager/2576/

1. Start "Windows Task Manager"
2. Go to the Users tab.
3. Look at the columns(go to menu - View, Select columns, if you don't see it.)
4. Look at the column called "Client Name"
5. Win32_LogonSession will not give the information needed. As said, we have most of the information already. Just need the last columns mentioned.

Already in use: Win32_TerminalService, win32_logonsession, Win32_Process, Win32_ComputerSystem, and Win32_UserAccount. None of these give us the last bit of information we would like to see.

If you have XP or better, you can see these columns under Windows Task Manager.
0
 
LVL 42

Expert Comment

by:pcelba
ID: 39935103
You may obtain a list of connected users by executing qwinsta:

http://weblogs.asp.net/owscott/archive/2003/12/30/Managing-Terminal-Services-Sessions-Remotely.aspx

Cassia .NET library is probably the tool you are looking for: http://code.google.com/p/cassia/
0
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 

Author Comment

by:ypm
ID: 39935141
We know of qwinsta and it does not give the remote machine name of each logged on user.  We don't need the users list. As stated we already have that and more. We need the machine name of each logged on user.

Example:  1st user logged on as xyz with machine name of z123
                  2nd user logged on as pdq with machine name p123
                 and so on.

We need the machine names: z123, p123 for each logged on user.  We don't need the server name as that's obvious already.

Don't know how to be any more clearer than this.

We looked Cassia .NET library  and it does not provide the machine name.
Also we really don't want any third party libraries in this stand alone application. Right now it's all .net microsoft controls.
0
 
LVL 42

Expert Comment

by:pcelba
ID: 39935247
I fully understand what you need.

The question is Why to reinvent the wheel? Cassia is working solution which you can use.

If you don't like such solution then you may call the RDS API functions directly. They are simple and fully described here: http://msdn.microsoft.com/en-us/library/aa383833(v=vs.85).aspx

Usable source code is here: http://www.codeproject.com/Articles/111430/Grabbing-Information-of-a-Terminal-Services-Sessio

To obtain client PC name from known IP should not be difficult.
0
 

Author Comment

by:ypm
ID: 39935657
Ok, we are going to call this one a loss. The point is just not getting across.
The first url does not even come close to what we asked for.
If we had the ip address, it would be no problem to get the machine name without all the bloated code on code project .
We only have a user, id, and status.
Cassia does not seem to have the ability to enter a domain, a remote user, and a remote user password.
It works on a local machine.

A similar question was posted on this exchange and never really answered.
http://www.experts-exchange.com/Programming/Languages/.NET/Q_22550879.html
Using SET at the command prompt on the remote machine is not a solution.

We appreciate the effort and will leave this up here for one more day and then ask for it to be closed. Thanks for all your effort.
0
 
LVL 42

Expert Comment

by:pcelba
ID: 39936421
I know my posts did not answer your questions exactly as you would wish... I've been pointing to places where you can obtain relevant info (OK, not in all cases :-).

The WTSQuerySessionInformation calls in the last link should be your starting point. It gives you the IP address, user, domain etc. (Of course, IP can be the router IP in some cases.) The MSDN link on the same post contains all the RDS API functions described.

Hope somebody else will tell more.
0
 

Accepted Solution

by:
ypm earned 0 total points
ID: 39946015
Please close. No solution presented.
0
 

Author Closing Comment

by:ypm
ID: 39955456
No solution presented.
0

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
The purpose of this article is to demonstrate how we can use conditional statements using Python.
This video teaches viewers about errors in exception handling.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question