I get it. I used this function, which will determine which process the user is using. In my code, I determined that I was looking for the user name of the explorer.exe process.
Function GetUserName() As String Dim selectQuery As Management.SelectQuery = New Management.SelectQuery("Win32_Process") Dim searcher As Management.ManagementObjectSearcher = New Management.ManagementObjectSearcher(selectQuery) Dim y As System.Management.ManagementObjectCollection y = searcher.Get For Each proc As Management.ManagementObject In y Dim s(1) As String proc.InvokeMethod("GetOwner", CType(s, Object())) Dim n As String = proc("Name").ToString() If n = "explorer.exe" Then Return s(0) End If Next End Function
Index 0 will return username
Index 1 will return the domain name of the user
source share