VBS:ActiveX组件无法创建对象:' Citrix.ICAClient#39; 64位错误

时间:2015-03-29 03:11:39

标签: vbscript 32bit-64bit citrix

我有一个脚本,用于查找所有打开的Citrix连接,并断开与登录到Windows(Citrix Web Interface连接)的用户无关的任何连接。它在32位机器(XP或7)上运行得很好,但在64位机器上却不行。我知道它确实依赖于两个Citrix reg键( AllowLiveMonitoring & AllowSimulationAPI )和 WfIcaLib.dll ,它们位于不同的位置不同的架构。我认为这是我的脚本和64位的东西,但是当我从32位机器卸载Receiver时,我得到了同样的错误。当我重新安装时,错误消失了。没有特殊的安装开关或方法,只需定期安装3.4.300接收器。因此,虽然它必须是64位相关的,但它与Citrix相关,而不是只是 VBScript代码。

这是我的脚本,设置icaClient = CreateObject(“Citrix.ICAClient”)行是错误的地方。

提前致谢。 布赖恩

Option Explicit
Dim strWindowsUser
Dim icaClient
Dim sessionHandle
Dim numSessions
Dim sessionID
Dim sessionInfo
Dim ct
Dim wshNetwork

' Get the name of the generic Windows user logged in

Set wshNetwork = WScript.CreateObject("WScript.Network")
strWindowsUser = wshNetwork.UserName

' As the next user is logging into the workstation, look for any
' Citrix sessions not tied to the generic Windows user and disconnect
' the session. 
' If you don't want to disconnect, use a Logoff command as follows:
' icaClient.Logoff()

Set icaClient = CreateObject("Citrix.ICAClient")
sessionHandle = icaClient.EnumerateCCMSessions()
numSessions = icaClient.GetEnumNameCount(sessionHandle)x

For ct = 0 To numSessions - 1

sessionID = icaClient.GetEnumNameByIndex(sessionHandle, ct)
icaClient.StartMonitoringCCMSession sessionID, True

'SessionServer = 0,
'SessionUsername = 1
'SessionDomain = 2
sessionInfo = icaClient.GetSessionString(1)
If lcase(sessionInfo) <> lcase(strWindowsUser) Then
    icaClient.Disconnect()
End If

icaClient.StopMonitoringCCMSession sessionID 

Next

icaClient.CloseEnumHandle sessionHandle

1 个答案:

答案 0 :(得分:2)

尝试手动指定64位cscript.exe

C:&gt;%windir%\ syswow64 \ cscript.exe script.vbs

我没有机器试试这个,但这是我过去为我工作的。

编辑:测试你的代码,它在硬编码64位cscript时有效。我使用的是Windows 8.1(x64)和Receiver 4.2(ICA Client 14.2)


c:\tools>cscript.exe text.vbs
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.

c:\tools\text.vbs(22, 1) Microsoft VBScript runtime error: ActiveX component can't create object: 'Citrix.ICAClient'

c:\tools>%windir%\syswow64\cscript.exe text.vbs
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.

c:\tools>