Solved

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

Posted on 2014-03-14
9
1,576 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
Comment Utility
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
Comment Utility
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 41

Expert Comment

by:pcelba
Comment Utility
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
 

Author Comment

by:ypm
Comment Utility
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 41

Expert Comment

by:pcelba
Comment Utility
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
Comment Utility
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 41

Expert Comment

by:pcelba
Comment Utility
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
Comment Utility
Please close. No solution presented.
0
 

Author Closing Comment

by:ypm
Comment Utility
No solution presented.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Problem with SqlConnection 5 109
Where to begin studying? 5 63
.NET Error 7 41
Make a border less form movable 2 11
Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.

771 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now