欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

QTP的那些事--通过WMI获取session中的用户信息的验证码

程序员文章站 2022-05-05 08:57:47
...
 
代码如下:获取相应的session中的值
strComputer = "."   
Set objWMI = GetObject("winmgmts:" _
              & "{impersonationLevel=impersonate}!\\" _
              & strComputer & "\root\cimv2")


Set colSessions = objWMI.ExecQuery _
    ("Select * from Win32_LogonSession Where LogonType = 10")


If colSessions.Count = 0 Then
   Wscript.Echo "No interactive users found"
Else
   WScript.Echo "RDP Sessions:"
   For Each objSession in colSessions

     Set colList = objWMI.ExecQuery("Associators of " _
         & "{Win32_LogonSession.LogonId=" & objSession.LogonId & "} " _
         & "Where AssocClass=Win32_LoggedOnUser Role=Dependent" )
     For Each objItem in colList
       WScript.Echo "Username: " & objItem.Name & " FullName: " & objItem.FullName
     Next
   Next
End If
 
 
参考链接:http://*.com/questions/898757/vb-using-wmi-get-logged-in-users

转载于:https://www.cnblogs.com/alterhu/archive/2012/05/15/2501886.html