Computer Performance, Logon Scripts

Error 800A01C2 - Wrong number of arguments of invalid property assignment.

Troubleshooting Error 800A01C2 - Wrong number of arguments of invalid property assignment.

Error 800A01C2 is a tricky problem.  Check to see if your script needs an extra 'Set' Command

Introduction to Code 800A01C2

Error code, 800A01C2 occurs when you execute a VBScript.  This is a runtime error, therefore check the names of your objects.  Error 800A01C2 - Object not a collection

The Symptoms you get

The script does not execute as you had hoped. Instead you get a message box like this picture:  (Screen shot kindly sent in by Jim Wells.)

The Cause of Code 800A01C2

The best clue to the error comes at the end of the line, the word 'objUser'.  objUser is a valid object and term, therefore we need to investigate what is missing.  I solved the problem by comparing with another script, which executed perfectly.  It turned out that 'Set' was required in front of objUser.

Incidentally, Source: reports a runtime error not a compilation error, this means you are looking not for a pure syntax problem, but a fault logic error.  In the case of runtime errors, you can use this temporary work around.  Add this statement just before the line which errors: On Error Resume Next.

The Solutions Wrong number of arguments of invalid property assignment.

Check the names in your script, pay particular attention to object names.  Note: The Line: 6 Char: 1  In this case it is not Char 1 to blame, more that there is something wrong and none of the line can execute.  In this case it should be Set objUser =

As a last resort, in the case of runtime errors, you can add this line:
On Error Resume Next.

Example of Error 800A01C2 Script

Note: The Line: 6 objUser

The script needs a 'Set' command before objUser

 

'CREATE USER AND SET PASSWORD
strcn = bilbo56
strsam= bilbo56
strpasswd = pauline1
Set objOU=GetObject("LDAP://ou=Droitwich,dc=cp,dc=com")
objUser = objOU.Create("User","cn=bilbo56")
objUser.Put "sAMAccountName","bilbo56"
ObjUser.SetInfo
objUser.SetPassword strpasswd
 

 

Corrected Version

 

'CREATE USER AND SET PASSWORD
strcn = bilbo56
strsam= bilbo56
strpasswd = pauline1
Set objOU=GetObject("LDAP://ou=Droitwich,dc=cp,dc=com")
Set objUser = objOU.Create("User","cn=bilbo56")
objUser.Put "sAMAccountName","bilbo56"
ObjUser.SetInfo
objUser.SetPassword strpasswd
 

 


Computer Training Software - Recommended Training VideosGuy Thomas recommends Computer Training Software.  Their topics and material are ideal for getting you started with VBScript.  The videos are easy to follow and you can control the pace.  Try their free demo material and then see if you want to buy the full package. See more about VB Script Training CD.


Do you have a good example of this error?  If so, then email me I will publish it with a credit to you:

Do you need extra help?

For interpreting the WSH messages check Diagnose 800 errors.

For general advice try my 7 Troubleshooting techniques

 

 *


Google

WebComputerperformance.co.uk

GFi Events Manager

Guy Recommends: GFi EventsManager

Here is a solution to monitor, manage and archive thousands of events that are generated by devices across your entire network.  Get your free evaluation copy of GFI EventsManager.

 

Home Copyright © 1999-2008 Computer Performance LTD All rights reserved

Please report a broken link, or an error.