Avatar of lucifer82
lucifer82
Flag for Hong Kong

asked on 

Object not a collection error when running VBScript at login

I'm trying to run this VBScript through kix for Citrix login script. The VBScript runs fine when I run it manually after user has logged into the Citrix. However I want it to run by kix calling the vbscript. It calls fine but it doesn't seem to run too well at the moment.

VBScript forces changes of the timezone for citrix user

The error message I get is

AEDT.vbs(29, 1) Microsoft VBScript runtime error: Object not a collection

AEDT.vbs is the vbscript file I'm running from kix command


Const HKEY_CLASSES_ROOT   = &H80000000
Const HKEY_CURRENT_USER   = &H80000001
Const HKEY_LOCAL_MACHINE  = &H80000002
Const HKEY_USERS          = &H80000003
 
Const REG_SZ        = 1
Const REG_EXPAND_SZ = 2
Const REG_BINARY    = 3
Const REG_DWORD     = 4
Const REG_MULTI_SZ  = 7
 
uBinary = Array(&Ha8,&Hfd,&Hff,&Hff,&H00,&H00,&H00,&H00,&Hc4,&Hff,&Hff,&Hff,&H00,&H00,&H04,&H00,&H00,&H00,&H01,&H00,&H03,&H00,&H00,&H00,&H00,&H00,&H00,&H00,&H00,&H00,&H0a,&H00,&H00,&H00,&H01,&H00,&H02,&H00,&H00,&H00,&H00,&H00,&H00,&H00)
 
' Chose computer name, registry tree and key path
'
strComputer = "." ' Use . for current machine
hDefKey = HKEY_CURRENT_USER
strKeyPath = "Software\Citrix\SessionTimeZone\"
 
' Connect to registry provider on target machine with current user
'
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
 
' Enum the subkeys of the key path we've chosen
'
oReg.EnumKey hDefKey, strKeyPath, arrSubKeys
 
For Each strSubkey In arrSubKeys
 
  strKeyPath = strKeyPath + strSubkey
  
oReg.SetStringValue hDefKey, strKeyPath, "Display", "AUS Eastern Standard Time"
oReg.SetStringValue hDefKey, strKeyPath, "Dlt", "AUS Eastern Daylight Time"
oReg.SetBinaryValue hDefKey, strKeyPath, "TZI", uBinary
oReg.SetDWORDValue hDefKey, strKeyPath, "UseRegTimeZone", "00000001"
 
Next

Open in new window

Visual Basic ClassicCitrixVB Script

Avatar of undefined
Last Comment
RobSampson

8/22/2022 - Mon