Click here to Skip to main content
11,485,965 members (80,954 online)

Visual Basic

 
AnswerRe: Monitoring Network Usage For Remote Users Pin
Eddy Vluggen13-Nov-12 12:44
memberEddy Vluggen13-Nov-12 12:44 
QuestionScan Multipage Tiff Image For A Barcode Pin
daveofgv12-Nov-12 5:07
memberdaveofgv12-Nov-12 5:07 
AnswerRe: Scan Multipage Tiff Image For A Barcode Pin
Eddy Vluggen12-Nov-12 11:54
memberEddy Vluggen12-Nov-12 11:54 
QuestionGetting All Logged On Users and IP VB.net Pin
DinoRondelly12-Nov-12 4:39
memberDinoRondelly12-Nov-12 4:39 
I am trying to get all logged on users and their IPAddresses and display them in a data grid veiw in a windows form using VB.net I have tried the below code and it appears to get the users on a windows 7 machine but not on servers. Any information on this would be greatly appreciated.

Public Shared Function GetUsers() As List(Of Users)
 
    Dim UserList As New List(Of Users)
 
    Try
        ' WhereDomain=""BLABLA"""
        Using searcher = New ManagementObjectSearcher("root\CIMV2", "SELECT * FROM Win32_LogonSession WHERE LogOnType = 2")
 
            For Each queryObj As ManagementObject In searcher.Get()
 
                Dim qry As String = "Associators of " _
                                 & "{Win32_LogonSession.LogonId=" & queryObj.GetPropertyValue("LogonId") & "} " _
                                 & "Where AssocClass=Win32_LoggedOnUser Role=Dependent"
 
                Using iSearch = New ManagementObjectSearcher(qry)
 
                    For Each res As ManagementObject In iSearch.Get()
 
                        Dim ret As New Users(res.GetPropertyValue("Name"), _
                                         "", "")
 
                        UserList.Add(ret)
                    Next
 

                End Using
            Next
        End Using
 
        Return UserList
 
    Catch err As ManagementException
 
        MessageBox.Show(err.Message)
        Return UserList
 
    End Try
 
End Function

AnswerRe: Getting All Logged On Users and IP VB.net Pin
Dave Kreskowiak12-Nov-12 5:37
mvpDave Kreskowiak12-Nov-12 5:37 
GeneralRe: Getting All Logged On Users and IP VB.net Pin
DinoRondelly12-Nov-12 5:44
memberDinoRondelly12-Nov-12 5:44 
GeneralRe: Getting All Logged On Users and IP VB.net Pin
Dave Kreskowiak12-Nov-12 5:52
mvpDave Kreskowiak12-Nov-12 5:52 
GeneralRe: Getting All Logged On Users and IP VB.net Pin
DinoRondelly12-Nov-12 5:55
memberDinoRondelly12-Nov-12 5:55 
GeneralRe: Getting All Logged On Users and IP VB.net Pin
Dave Kreskowiak12-Nov-12 6:55
mvpDave Kreskowiak12-Nov-12 6:55 
GeneralRe: Getting All Logged On Users and IP VB.net Pin
DinoRondelly12-Nov-12 7:11
memberDinoRondelly12-Nov-12 7:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web01 | 2.8.150520.1 | Last Updated 26 May 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid