Wednesday, 21 May 2014

How to resolve "Automation error: the system cannot find the file specified" COM errors

I was running a COM object from somewhere (in this case it was a VBScript in Excel) and getting the error, "Automation error: the system cannot find the file specified."

The VBScript snippet was like this:

Dim obj As Object
Set obj = CreateObject("Example.ComObject") ' <<< This line gave the exception.

So I ran a trace using Process Monitor and looked at all the failed RegOpenKey operations.

This showe me that, when trying to find a COM object, Windows looks in the registry in the HKCU hive first, then HKCR, looking at these entries:
  1. HKCU\Software\Classes\Example.ComObject - none found in my circumstance.
  2. HKCR\ExampleComObject\CLSID - contains the <CLSID>, e.g. {7D82...F}.
  3. HKCR\CLSID\<CLSID>\InprocServer32\CodeBase - contains the path to the DLL (see screen shot below).
In my situation, I found that the path in the CodeBase was no longer valid, so I restored the file to that path, restarted the program that gave the error, and then the problem was resolved.

No comments:

Post a Comment