Windows Scripting can't find reference

ε祈祈猫儿з 提交于 2019-12-13 06:59:04

问题


I have a windows script file that doesn't work anymore.

The script look like this

<job>
    <reference object="Some.Component.1" />
    <script language="VBScript">

x = CreateObject("Some.Component.1")
MsgBox TypeName(x)

    </script>
</job>

When I run the script with cscript or wscript I get the error

Windows Script Host: Cannot find the type library for this reference : Some.Component.1

The error code is 0x80040068 which means "Invalid index". (I tried to removed the .1 index but it didn't work)

The strange thing is that if I remove the line <reference object="Some.Component.1"/>, the CreateObject line works and the object is created.

I know the script worked about a year ago. The "Some.Component" library has been updated but since CreateObject works I have no idea what is wrong with it.

I have tested the script on Server 2008 R2 (64bit), Server 2003 (32bit) and Windows 7 (64bit) with the same error.

Some.Component is 32 bit. For the 64bit machines I used cscript, wscript in the SysWow64 folder.

(I need the <reference../> to access enums within the component)


回答1:


The type library is not registered. This is a different and separate thing from the object being registered. Usually the control will do both.

I suggest you first try unregistering and re-registering the DLL.

regsvr32.exe /u c:\path\to\control.dll
regsvr32.exe c:\path\to\control.dll

If that doesn't work, try using RegTLib.exe to register the type library (*.tlb) directly.

regtlib.exe c:\path\to\control.dll

OR

regtlib.exe c:\path\to\control.tlb

Note that the type library may be a separate file or may be embedded in the DLL.

For more on regTLib.exe see here:

  • http://support.microsoft.com/kb/292744


来源:https://stackoverflow.com/questions/7256920/windows-scripting-cant-find-reference

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!