问题
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