WMI Example: Win32_Process: List Logon User All Windows Platforms '--------------------------------------------------------------------------------------- ' Vbscript , not VBA ' Save text file and execute : List_LogonUser.vbs ' DateTime : ' Author : ' Purpose : List Logon User '--------------------------------------------------------------------------------------- strComputer = InputBox("Enter Computer Name") Err.Clear If Len(strComputer) = 0 Then Wscript.Quit End If On Error Resume Next Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!//" & strComputer & "\root\cimv2") If Err.Number <> 0 Then Wscript.Echo "Computer not found or Unavailable" Else Set colComputer = objWMIService.ExecQuery _ ("Select * from Win32_ComputerSystem") For Each objComputer In colComputer Wscript.Echo "Logged-on user: " & objComputer.UserName Next End If
[此贴子已经被作者于2007-2-26 9:08:15编辑过] |