How to get all logged on user on a machine

S

Steven

Hi Gurus,
Is there any way to find out all the useres currently logged on my machine.
I am using framework 2.0 with VB.

I'll appreciate any help I get.
Thanks, Steven.
 
K

kimiraikkonen

Hi Gurus,
Is there any way to find out all the useres currently logged on my machine.
I am using framework 2.0 with VB.

I'll appreciate any help I get.
Thanks, Steven.

What do you mean by logged on your machine? Logged on your LAN or
workgroup..?
 
K

kimiraikkonen

Workgroups

Steven

For that purpose,
You can use "net view" shell command and redirect output to your
control.
For example you can redirect shell output to textbox using:

Dim start_info As New ProcessStartInfo("cmd.exe", "/c net view")
start_info.UseShellExecute = False
start_info.CreateNoWindow = True
start_info.RedirectStandardOutput = True
start_info.RedirectStandardError = True

' Make the process and set its start information.
Dim proc As New Process()
proc.StartInfo = start_info

' Start the process.
proc.Start()

' Attach to stdout and stderr.
Dim std_out As IO.StreamReader = proc.StandardOutput()


' Display the results to your textbox1
TextBox1.Text = std_out.ReadToEnd()


' Clean up.
std_out.Close()

proc.Close()


But i suppose System.net.dns class provides LAN IPs and you can loop
through the array.
 
S

Steven

I think I did not mention it clearly.
What I want is all the user loginname and machine name who have logged in to
a system using remote desktop connection or VPN.

Sorry for the confusion.
Let me know if you can help me on this.

Thanks Steven
 
Z

zacks

I think I did not mention it clearly.
What I want is all the user loginname and machine name who have logged in to
a system using remote desktop connection or VPN.

Your question is still confusing. Do you want to know just who the
currently logged on user is and whether this user logged in via remote
desktop or VPN?

OR

Do you want a list of all usernames who have ever logged into the
computer with remote desctop connection or VPN?
 
S

Steven

Let me try again.
On our server more then one person/machine can connect using Remote desktop
connection or VPN.
They can connect anytime and from anywhere.
Sometimes there are 5 users connected and doing something on the server.

I want to know all the machine/ClientName connected to the server at this
moment.

Please let me know if even this is not clear. I will try again.

Thanks Steven


I think I did not mention it clearly.
What I want is all the user loginname and machine name who have logged in
to
a system using remote desktop connection or VPN.

Your question is still confusing. Do you want to know just who the
currently logged on user is and whether this user logged in via remote
desktop or VPN?

OR

Do you want a list of all usernames who have ever logged into the
computer with remote desctop connection or VPN?
 
K

kimiraikkonen

Let me try again.
On our server more then one person/machine can connect using Remote desktop
connection or VPN.
They can connect anytime and from anywhere.
Sometimes there are 5 users connected and doing something on the server.

I want to know all the machine/ClientName connected to the server at this
moment.

Please let me know if even this is not clear. I will try again.

Thanks Steven




Your question is still confusing. Do you want to know just who the
currently logged on user is and whether this user logged in via remote
desktop or VPN?

OR

Do you want a list of all usernames who have ever logged into the
computer with remote desctop connection or VPN?








- Show quoted text -

Steven,
In my code you get all the clients' machine name using "net view"
shell command and redirecting output to a text-based control like
textbox, that are included on your workgroup, please apply and see and
let me know if you have any difficulty.

Regards,

Onur Güzel
 
S

Steven

Your code gives me all use users logging on in network.
But what I want is all the users logged on on a server using Remote Desktop
Connection/VPN.

Thanks, Steven

Let me try again.
On our server more then one person/machine can connect using Remote
desktop
connection or VPN.
They can connect anytime and from anywhere.
Sometimes there are 5 users connected and doing something on the server.

I want to know all the machine/ClientName connected to the server at this
moment.

Please let me know if even this is not clear. I will try again.

Thanks Steven




Your question is still confusing. Do you want to know just who the
currently logged on user is and whether this user logged in via remote
desktop or VPN?

OR

Do you want a list of all usernames who have ever logged into the
computer with remote desctop connection or VPN?








- Show quoted text -

Steven,
In my code you get all the clients' machine name using "net view"
shell command and redirecting output to a text-based control like
textbox, that are included on your workgroup, please apply and see and
let me know if you have any difficulty.

Regards,

Onur Güzel
 
F

Family Tree Mike

Norman Diamond responded with this to a very similar question on the C#
board. It should apply to VB as well.

================
There can be 0 or more current logged in users. If you want all of the 0 or
1 users who are currently logged in at the console then P/Invoke to
WTSGetActiveConsoleSessionId and WTSQuerySessionInformation. If you want
all of the users then you'll need to call WTSQuerySessionInformation in a
loop.

Warning: Only call the Unicode version of WTSQuerySessionInformation. If
your application runs in ANSI then explicitly call the Unicode version
WTSQuerySessionInformationW and convert the result to ANSI by calling
WideCharToMultiByte. From C# you mostly don't have to worry about this,
just make sure that your P/Invoke declaration specifies the Unicode version.
================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top