From: karim on
Hi All,
Is there a way in vb to find all logged in users on a network? I know
using cmd, you can type >>nbtstat -a [MachineName]<< and it would show how's
logged on. so would we be able to do something like that using vb? and would
we be able to view all logged in users without typing the machine name?

Thanks for the help.
From: Onur Güzel on
On Jan 27, 8:33 am, karim <ka...(a)discussions.microsoft.com> wrote:
> Hi All,
>      Is there a way in vb to find all logged in users on a network? I know
> using cmd, you can type >>nbtstat -a [MachineName]<< and it would show how's
> logged on. so would we be able to do something like that using vb? and would
> we be able to view all logged in users without typing the machine name?
>
> Thanks for the help.

You can also try "net view" command from command prompt and redirect
stdout to your program as follows:

' -------------------------------------------
' Set start information.
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 in a textbox
TextBox1.Text = std_out.ReadToEnd()


' Clean up.
std_out.Close()

proc.Close()

' -------------------------------------------

HTH,

Onur Güzel
From: karim on
Thank you very much. Works great.

"Onur Güzel" wrote:

> On Jan 27, 8:33 am, karim <ka...(a)discussions.microsoft.com> wrote:
> > Hi All,
> > Is there a way in vb to find all logged in users on a network? I know
> > using cmd, you can type >>nbtstat -a [MachineName]<< and it would show how's
> > logged on. so would we be able to do something like that using vb? and would
> > we be able to view all logged in users without typing the machine name?
> >
> > Thanks for the help.
>
> You can also try "net view" command from command prompt and redirect
> stdout to your program as follows:
>
> ' -------------------------------------------
> ' Set start information.
> 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 in a textbox
> TextBox1.Text = std_out.ReadToEnd()
>
>
> ' Clean up.
> std_out.Close()
>
> proc.Close()
>
> ' -------------------------------------------
>
> HTH,
>
> Onur Güzel
> .
>
From: karim on

But is there a way to view the logged on users on these clients?

Thank you...
From: Onur Güzel on
On Jan 27, 10:24 am, karim <ka...(a)discussions.microsoft.com> wrote:
> But is there a way to view the logged on users on these clients?
>
> Thank you...

Well, you can use WMI for a in-depth information. For example,
assuming your domain name is "blabla": you can get them using: (Add
reference to System.Management.dll)

'----------------------------------------------------
Try

Dim searcher As New ManagementObjectSearcher _
("root\CIMV2", "SELECT * FROM Win32_UserAccount Where
Domain=""BLABLA""")

For Each queryObj As ManagementObject In searcher.Get()

MsgBox(queryObj.GetPropertyValue("Name").ToString)

Next

Catch err As ManagementException

MessageBox.Show(err.Message)

End Try
End Sub

'----------------------------------------------------

HTH,

Onur Güzel