| |
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
|
|