We help IT Professionals succeed at work.

Windows Script host "error" running script "object required"

Medium Priority
2,429 Views
Last Modified: 2007-12-19
I am getting an error running a loging script, below is ther start of the script and it errors on line 43, char 1, error "object required: 'ObjgroupDict', Code 800A01A8, source MS VBScript runtime error.   If I run it on a W2K3 server there is no error, if I run it on W2K server it presents this error.  Is there something about W2K3, .net version, etc.?  pease help

btw: line 43 is:

MemberOf = CBool(ObjGroupDict.Exists(strKey))


'*******************************************************************
'*                    Variable Declarations                        *
'*******************************************************************

Option Explicit ' Force explicit declarations

Dim WSHNetwork
Dim WSHFSO
Dim WSHShell
Dim strUserName ' Current user
Dim strUserDomain ' Current User's domain name
Dim ObjGroupDict ' Dictionary of groups to which the user belongs
Dim objshell
Dim objExecObject
Dim objUser, objGroup

Set WSHNetwork = WScript.CreateObject("WScript.Network")
Set WSHFSO = CreateObject("Scripting.FileSystemObject")


'*******************************************************************
'*                    Get Variables Ready                          *
'*******************************************************************

strUserName = ""
While strUserName = ""
WScript.Sleep 100 ' 1/10 th of a second
strUserName = WSHNetwork.UserName
Wend
strUserDomain = WSHNetwork.UserDomain


Function MemberOf(ObjDict, strKey)
MemberOf = CBool(ObjGroupDict.Exists(strKey))
End Function


Function CreateMemberOfObject(strDomain, strUserName)


Set CreateMemberOfObject = CreateObject("Scripting.Dictionary")
CreateMemberOfObject.CompareMode = vbTextCompare
Set objUser = GetObject("WinNT://" _
& strDomain & "/" _
& strUserName & ",user")
For Each objGroup In objUser.Groups
CreateMemberOfObject.Add objGroup.Name, "-"
Next
Set objUser = Nothing

End Function


'*******************************************************************
'*                    Login Script Starts Now                      *
'*******************************************************************
Comment
Watch Question

Commented:
You have declare the variable ObjGroupDict but have not assign any object instance to it.

Without assigning and object instance to ObjGroupDict, where are are you going to find the Exist method?
Perhaps the line;
    MemberOf = CBool(ObjGroupDict.Exists(strKey))

should actually be ...
    MemberOf = CBool(ObjDict.Exists(strKey))

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Commented:
It's the same thing. Where is your object instance for ObjDict? Try this.

Function MemberOf(ObjDict, strKey)
    set ObjGroupDict = CreateObject("Scripting.Dictionary")
    MemberOf = CBool(ObjGroupDict.Exists(strKey))
End Function

Commented:
or

Function MemberOf(ObjDict, strKey)
    set ObjDict = CreateObject("Scripting.Dictionary")
    MemberOf = CBool(ObjDict.Exists(strKey))
End Function
We need to see the rest of your scripting code to know one way or another ....
Leo EikelmanDirector, IT and Business Development

Commented:
yeah I don't understand

you created a variable

Dim ObjGroupDict

but you havent set the variable to dictionary object.

How can u see if it exists when you havent even set it to anything?

Leo
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.