如何从 WMI 对象引用中获取 WMI 对象 [英] How to get WMI object from a WMI object reference

查看:26
本文介绍了如何从 WMI 对象引用中获取 WMI 对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 WMI 执行一些 Citrix 工作,特别是搜索要注销的特定用户.首先,我必须枚举一个名为 MetaFrame_Session 的对象,它列出当前会话,然后我必须从中检索一个名为 Citrix_User 的对象,该对象具有用户名.

I'm using WMI to do some Citrix work, specifically to search for a particular user to log off. First I have to enumerate an object called MetaFrame_Session, which lists current sessions, then from that I have to retrieve an object called Citrix_User, which has the user name.

Session 对象包含对 User 对象的引用,但我对 WMI 不是很熟悉,而且我对如何从引用中获取实际对象感到困惑.如何在 VBScript 中执行此操作的示例将非常有帮助

The Session object contains a reference to the User object, but I am not very familiar with WMI and I'm stumped as to how to get the actual object from the reference. Examples of how to do this in VBScript would be very helpful

推荐答案

您似乎无法在此其他论坛,但使用 WMI 注销 Citrix 会话的代码已发布此处 如下,Haydn Davies 对于一台 Citrix 服务器:

Seems you couldn't find an answer on this other forum, either, but the code to log off a Citrix session using WMI was kindly posted here as follows by Haydn Davies for one Citrix server:

' Logoff Disconnected Sessions
' If you want to logoff active sessions as well, change the query to include
' cActive
On Error Resume Next

Const cActive = 0
Const cDisconnected = 4
Const strComputer = "."

Set objWMICitrix = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\citrix")
Set colItems = objWMICitrix.ExecQuery ("Select * from Metaframe_Session Where sessionstate = " & cDisconnected)

For Each objItem in colItems
if (objItem.SessionID > 0) and (objItem.SessionID < 65530) then
objItem.Logoff
end if
Next

Set objWMICitrix = Nothing

请参阅此处以获取有关如何操作的代码获取 Citrix VirtualIP,因为它可能有助于作为技术参考.此外,如果您发现服务器上的 WMI 损坏,请参阅此处进行修复.

See here for code on how to get a Citrix VirtualIP, since it might help as reference for techniques. Also, if you find the WMI is broken on the server, see here for repairing.

这篇关于如何从 WMI 对象引用中获取 WMI 对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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