VBS: ActiveX component can't create object: 'Citrix.ICAClient' errror on 64-bit

丶灬走出姿态 提交于 2019-12-13 19:57:01

问题


I have a script that looks for all open Citrix connections and disconnects any of them that aren't associated with the user logged in to Windows (Citrix Web Interface connections). It works perfectly fine on 32-bit machines (XP or 7) but not on 64-bit. I know it does rely on two Citrix reg keys (AllowLiveMonitoring & AllowSimulationAPI) and the WfIcaLib.dll, which will be in different locations on different architecture. I thought it was something with my script and 64-bit, but when I uninstall the Receiver from a 32-bit machine, I get the same exact error. And when I reinstall, the error goes away. No special install switches or method, just a regular install of the 3.4.300 Receiver. So although it must be 64-bit related, it's with Citrix and not just the VBScript code.

Here is my script, the Set icaClient = CreateObject("Citrix.ICAClient") line is where it errors.

Thanks in advance. Brian

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:


Try manually specifying the 64bit cscript.exe

C:>%windir%\syswow64\cscript.exe script.vbs

I don't have a machine to try this on, but this is what's worked for me in the past.

Edit: Tested your code and it works when hardcoding the 64bit cscript. I'm using Windows 8.1 (x64) and 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>


来源:https://stackoverflow.com/questions/29325231/vbs-activex-component-cant-create-object-citrix-icaclient-errror-on-64-bit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!