Web Development



How to fix Error in script - "Object not a collection" 800A01C3?

By ACox1976 ·
I'm trying to set up a renaming script but I'm getting an error at line 15, character 2 which says "Object not a collection" (error code 800A01C3). This is the script (numbered to make it easier to identify the error line):

1 Const ForReading = 1
3 strComputer = "."
4 Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
6 Set objFSO = CreateObject("Scripting.FileSystemObject")
7 Set objFile = objFSO.OpenTextFile ("C:\Users\gzqj79\Desktop\Renaming.txt", ForReading)
9 Do Until objFile.AtEndOfStream
10 strLine = objFile.ReadLine
11 arrParts = Split (StrLine, ",")
12 strFile = "C:\\Photos\\" & arrParts(0)
13 Set colItems = objWMIService.ExecQuery _
14 ("Select * From CIM_Datafile Where Name = '" & StrFile & "'")
15 For Each objItem in colItems
16 strNewName = "C:\Photos\" & arrParts(1)
17 objItem.Rename strNewName
21 objFile.Close

Any help would be appreciated!
Thanks --

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Collapse -

Um. A guess

by Tony Hopkinson In reply to How to fix Error in scrip ...


There's a third argument for ExecQquery called flags, one of them is return when complete, the default which you have is return immediate...

Is this just 'playing/investigating', after all you have the old and new filenames, be easier to just execute a rename command, than mess about with WMI in this case.

Collapse -

Make sure your L and I are not mixed up

by robo_dev In reply to How to fix Error in scrip ...

lower case L and I look the same on this screen

coL Items not coLLtems same with obj Item


Troubleshooting Code 800A01C3 - Object not a collection

Introduction to Code 800A01C3

Error code, 800A01C3 occurs when you execute a WMI / VBScript. This is a runtime error check the names of your objects. Go through the spelling of the object names with a fine toothcomb.

some viruses exploit this as a D1L file and a DLL file look the same with screen font.

Collapse -

Got rid of WMI...

by ACox1976 In reply to How to fix Error in scrip ...

I ended up just using objFSO.MoveFile and ditched the WMI altogether...worked beautifully. Thanks for all your input --

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\Renaming.txt",1)

Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
arrParts = Split(strLine,",")
strFile = "C:\Photos\" & arrParts(0)
On Error Resume Next
objFSO.MoveFile strFile, "C:\Photos\" & arrParts(1)


Related Discussions

Related Forums