Try this code :
Imports System.Management
Imports System.DirectoryServices
Imports Microsoft.Win32
Imports System.Runtime.InteropServices
Module Module1
Dim objManagementClass As ManagementClass
Dim objManagementScope As ManagementScope
Dim objManagementBaseObject As ManagementBaseObject
Public Strcomputer As String = ""
Sub Main()
Dim WMIScope As Management.ManagementScope
Dim WMIConnectionOptions As New Management.ConnectionOptions
Dim strRootDomain As String
Dim objRootLDAP As DirectoryEntry
Dim query As ManagementObjectSearcher
Dim queryCollection As ManagementObjectCollection
Dim oq As New System.Management.ObjectQuery
Dim mo As New ManagementObject
Dim UserDomain As String
Dim UserID As String
Dim StrLoggedUserSID() As Byte
Try
Dim Strcomputer As String = My.Application.CommandLineArgs.Item(0)
With WMIConnectionOptions
.Impersonation = System.Management.ImpersonationLevel.Impersonate
.Authentication = System.Management.AuthenticationLevel.Packet
End With
WMIScope = New Management.ManagementScope("\\" & _
Strcomputer & "\root\cimv2", WMIConnectionOptions)
objRootLDAP = New DirectoryEntry("LDAP://RootDSE")
strRootDomain = objRootLDAP.Properties.Item("rootDomainNamingContext").Value.ToString
oq = New System.Management.ObjectQuery("SELECT UserName from Win32_ComputerSystem")
query = New ManagementObjectSearcher(WMIScope, oq)
queryCollection = query.Get()
For Each oReturn As ManagementObject In queryCollection
If Not oReturn("UserName") Is Nothing Then
Console.WriteLine(oReturn("UserName").ToString)
Else
Console.WriteLine("Not logged in")
End If
Next
Catch ex As Exception
Console.WriteLine(ex.ToString)
End Try
End Sub