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
Solved

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

Posted on 2014-03-14
9
1,687 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 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
The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

 

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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

856 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