Question

Locked

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
2
3 strComputer = "."
4 Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
5
6 Set objFSO = CreateObject("Scripting.FileSystemObject")
7 Set objFile = objFSO.OpenTextFile ("C:\Users\gzqj79\Desktop\Renaming.txt", ForReading)
8
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
18 NEXT
19 LOOP
20
21 objFile.Close

Any help would be appreciated!
Thanks --

This conversation is currently closed to new comments.

4 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

Um. A guess

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

but
http://technet.microsoft.com/en-us/library/ee176596.aspx

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

http://www.computerperformance.co.uk/Logon/code/code_800A01C3.htm

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)
Loop

objFile.Close

Back to Web Development Forum
4 total posts (Page 1 of 1)  

Software Forums