Here's the bare necessity:
Dim inputStr, UserName, Domain, splitInput, sName, oArgs, SessionDim oUser, userFullName, userHome, fService, LoggedOn, q, ss'On Error Resume Nextq = Chr(34)Domain = "Domain"username = inputbox("Enter username: ")Set oUser = GetObject("WinNT://" & Domain & "/" & UserName & ",user")userFullName = oUser.FullNameuserHome = oUser.HomeDirectorysName = Split(userHome, "\")Set fService = GetObject("WinNT://" & Domain & "/" & sName(2) & "/LanmanServer")Set ss = fService.SessionsFor Each Session In ssIf LCase(Session.User) = LCase(UserName) ThenLoggedOn = LoggedOn & vbcr & Session.ComputerEnd IfNextIf LoggedOn = "" thenmsgbox "User " & q & UserName & q & " (" & userFullName & ") is not logged on.", 64, "Query:"ElseMsgBox "User " & q & UserName & q & " (" & userFullName & ") logged on to the following workstations: " & vbcr & vbcr & LoggedOn, , "Query:"End If
One of the cool things about this script is that it doesn't return the first one it finds, it returns a list of them.
So you may find a bunch of Citrix Servers. I have found it to be flaky at times and have never been able to get this to work with Windows 7... I think because of the LanmanServer part.
Anyways, enjoy!
No comments:
Post a Comment