Remote Computer User Information


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Remote Computer User Information

  1. #1
    Join Date
    May 2004
    Location
    Duluth MN
    Posts
    353

    Remote Computer User Information

    I'm trying to determine if an application is running on a remote computer.

    I ping the machine to determine it's online.

    I check the processes to see if the app is running.

    The problem is I don't know if someone is logged in (app should be runnning) or the computer is sitting at the login screen (app should not be running). How can I determine if someone is logged in?

    ...joe

  2. #2
    Join Date
    May 2004
    Location
    Duluth MN
    Posts
    353
    Looks like you can do this with WMI. This requires a reference to System.Management

    Code:
        Function LoggedIn(ByVal strMach As String) As Boolean
            Dim PROCNAME As String = "LoggedIn"
            Dim Result As Boolean = False
            Try
                Dim scope As New ManagementScope("\\" & strMach & "\root\cimv2")
                scope.Connect()
                If scope.IsConnected Then
                    Try
                        Dim query As New ObjectQuery("SELECT UserName from Win32_ComputerSystem")
                        Using searcher As New ManagementObjectSearcher(scope, query)
                            Dim queryCollection As ManagementObjectCollection
                            queryCollection = searcher.Get()
                            For Each m As ManagementObject In queryCollection
                                Result = (Not m("UserName") Is Nothing)
                            Next
                            queryCollection.Dispose()
                            searcher.Dispose()
                        End Using
                        query = Nothing
                    Catch ex As Exception
                        MessageBox.Show(ex.Message & " on " & strMach, PROCNAME & " Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                    End Try
                    scope = Nothing
                End If
            Catch ex As Exception
                MessageBox.Show(ex.Message & " on " & strMach, PROCNAME & " Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End Try
            Return Result
        End Function

    ...joe

  3. #3
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Sweet....thanks for posting your discovery.
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

Similar Threads

  1. Replies: 1
    Last Post: 08-23-2005, 07:33 AM
  2. Remote Machine Information
    By GRussell31 in forum .NET
    Replies: 2
    Last Post: 07-05-2005, 10:56 AM
  3. Shutdown remote computer
    By Chris in forum VB Classic
    Replies: 2
    Last Post: 02-22-2002, 05:57 PM
  4. Replies: 0
    Last Post: 03-08-2001, 12:54 PM
  5. Computer & User Authentication
    By David in forum Java
    Replies: 0
    Last Post: 08-29-2000, 05:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center