获取活动会话使用WMI(Win32_LogonSession也返回非活动/旧会话) [英] Get active sessions with wmi (Win32_LogonSession returns also inactive/old sessions)

查看:690
本文介绍了获取活动会话使用WMI(Win32_LogonSession也返回非活动/旧会话)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法,以显示与WMI只有活动会话? 问题是,Win32_LogonSession显示还处于非活动状态/断开的会话。

 管理​​范围范围=新的管理范围(ManagementPath.DefaultPath);
SelectQuery查询=新SelectQuery(Win32_LogonSession);
ManagementObjectSearcher搜索=新ManagementObjectSearcher(范围查询);
ManagementObjectCollection结果= searcher.Get();
的foreach(的ManagementObject莫结果)
{
    PrintWmiObject(MO);
}
 

这个输出是这样的

  

AuthenticationPackage - 的Kerberos

     

标题 -

     

描述 -

     

InstallDate -

     

LogonID的 - 10179411

     

LogonType - 10

     

名称 -

     

开始时间 - 20110617083244.547220 + 120

     

状态 -

解决方案

什么:

  SelectQuery查询=新SelectQuery(SELECT * FROM Win32_LogonSession其中LogonType = 10)
 

Is there a way to show only active sessions with wmi? The problem is that Win32_LogonSession shows also inactive/disconnected sessions.

ManagementScope scope = new ManagementScope(ManagementPath.DefaultPath);
SelectQuery query = new SelectQuery("Win32_LogonSession");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
ManagementObjectCollection results = searcher.Get();
foreach (ManagementObject mo in results)
{
    PrintWmiObject(mo);
}

The output of this is something like this

AuthenticationPackage - Kerberos

Caption -

Description -

InstallDate -

LogonId - 10179411

LogonType - 10

Name -

StartTime - 20110617083244.547220+120

Status -

解决方案

What about:

SelectQuery query = new SelectQuery("Select * from Win32_LogonSession Where LogonType = 10")

这篇关于获取活动会话使用WMI(Win32_LogonSession也返回非活动/旧会话)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆