Computer Performance, Logon Scripts

Code Error 800A0CC1 - Item cannot be found in the collection

Troubleshooting Code 800A0CC1 - Item cannot be found in the collection

Difficult error code to solve. You may need lateral thinking to cure 800A0CC1

Introduction to Code 800A0CC1

Error code, 800A0CC1 occurs when you execute a VBScript.Code 800A0CC1 - Item cannot be found in the collection

The Symptoms you get

The script does not execute as you had hoped.  Instead. Windows Scripting host generates a message box like this picture:

The Cause of Code 800A0CC1

Your VBScript contains an incorrect argument.   Note: The clue Source: ADODB.Recordset.

The Solution

The Windows Scripting Host gives us three useful clues, firstly, look on Line: 22, do count any remark or empty lines.  Secondly, the Char: number 1, is less useful as the error could be anywhere on that line.  Thirdly Expected 'Item not found....' is pointing us to the script problem.  This an obscure error, the problem is that the script is trying to display OU, but OU is not a valid property of the computer object.

Example of error 800A0CC1 Script

I admit that this is a specialist script in the sense that it has a hard-coded name of the domain.

Check the  & OU line.

 

' VBScript to display the XP machines in your Active Directory domain
' Guy Thomas February 2004.
' ******************************
Const ADS_SCOPE_SUBTREE = 2
objDom = "cn=computers,DC=cp,DC=com"
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.CommandText = _
"Select Name, Location, operatingSystemVersion from 'LDAP:// cn=computers,DC=cp,DC=com'" _
& " where objectClass='computer' " _
& " and operatingSystemVersion = '5.1 (2600)'"
objCommand.Properties("Page Size") = 500
objCommand.Properties("Timeout") = 20
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.Properties("Cache Results") = False
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
Wscript.Echo "Computer Name: " & objRecordSet.Fields("Name").Value & VBCr _
& "Version: " & objRecordSet.Fields("operatingSystemVersion").Value & VBCr _
& "OU: " & objRecordSet.Fields("ou").Value
objRecordSet.MoveNext
Loop

' End of Script

 

 

Corrected Version

With & "OU: " & objRecordSet.Fields("ou").Value removed.

 

' Computers.vbs
' Example VBScript to display the Computer Objects in your domain
' Guy Thomas February 2004.
' ******************************
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.CommandText = _
"Select Name, operatingSystemVersion from 'LDAP://dc=cp, dc=com'" _
& " where objectClass='computer' "
objCommand.Properties("Page Size") = 500
objCommand.Properties("Timeout") = 20
objCommand.Properties("Cache Results") = False
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
Wscript.Echo "Computer: " & objRecordSet.Fields("Name").Value & VbCr _
& "Version: " & objRecordSet.Fields("operatingSystemVersion").Value
objRecordSet.MoveNext
Loop

' End of example VBScript


 

 

 

Solarwinds IpMonitorTry a different solution, download SolarWinds ipMonitor

Here is my thinking, ipMonitor will give you valuable data about your network and servers.  This extra information just may unlock the solution to your error code.  One more thing, sometimes when troubleshooting you go around in circles; therefore if you try a different, but related approach, you may just crack the problem.  Free Download of SolarWinds ipMonitor

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 need extra help?

For interpreting the WSH messages check Diagnose 800 errors.

For general advice try my 7 Troubleshooting techniques

Give something back?

Would you like to help others?  If you have a good example of this error, then please email me, I will publish it with a credit to you:

 

 *


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.