Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Where is a user logged in.

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,3454
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Where is a user logged in.
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Where is a user logged in. - 6/20/2005 6:21:54 AM   
  spar75


Posts: 8
Score: 0
Joined: 6/20/2005
From:
Status: offline
Is there a way to find out with VB which computer (hostname) a user is logged into by searching with thier user ID? Thanks
 
 
Post #: 1
 
 Re: Where is a user logged in. - 6/27/2005 4:00:44 AM   
  vuthanht

 

Posts: 9
Score: 0
Joined: 6/16/2005
From: USA
Status: offline
Try this

'Find whether or not user is logged on, if logged on then which computer(s)?
'this script will read computer names from the computer_names.txt file.
const ForReading = 1
Set filesys = CreateObject("Scripting.FileSystemObject")
strUser = InputBox("This scrip will accept a user name and" & vbCRLF & "will return the current logged on computer(s)","Enter user Name","guesswho")
If strUser = "" Then
WScript.Quit
else
strUser="Domain_name\" & strUser
end if

FoundUser=""
Set filetxt = filesys.OpenTextFile("computer_names.txt", ForReading, False)
while not filetxt.AtEndOfStream
strComputer=filetxt.Readline
on error resume next
set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
if err.number=0 then
Set colComputer = objWMIService.ExecQuery ("Select * from Win32_ComputerSystem")
For Each objComputer in colComputer
If ucase(objComputer.UserName) = ucase(strUser) Then
Founduser=FoundUser & strComputer & vbcrlf
end if
Next
end if
wend
If FoundUser="" Then
MsgBox "User " & struser & " is not logged on"
else
Msgbox "User " & struser & " is logged on at computer(s):" & vbcrlf & vbcrlf & FoundUser
End If

(in reply to spar75)
 
 
Post #: 2
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Where is a user logged in. Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts