Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2014-03-14
9
Medium Priority
?
1,932 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
  • 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 43

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 43

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 43

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

927 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