Windows Script Components  

<registration> Element

Defines information used to register the script component as a COM component.

<registration progid="progID" classid="GUID" description="description"
   version="version" [remotable=remoteFlag]/>


<registration progid="progID" classid="GUID" description="description"
      version="version" [remotable=remoteFlag]>
      (registration and unregistration script)


(Optional) A text name that programmers use to reference your script component when creating an instance of it. For example, if your script component's program ID is Component.MyComponent, you can create an instance of it in Microsoft® Visual Basic using a statement such as the following:

Set Component = CreateObject("Component.MyComponent")

Note   Although a progid attribute is optional, you must include either a progid or a classid attribute (you can include both). If only the progid attribute is specified, the class ID is generated automatically. If only the class ID is created, then no progid is registered and the object can be created only by referencing the class ID directly.
(Optional) A GUID that you have generated using a class ID generation program (such as Uuidgen.exe). If you do not include a class ID, the registration program assigns a class ID to your script component.
(Optional) A text description of the script component that is stored in the registry and that is used in certain tools such as the Visual Basic object browser.
(Optional) A numeric version number that you assign. The version is appended to the program ID with a period (for example, MyComponent.1) when applications request a version-specific name. Use only numbers (decimal points are not allowed).
Note   The registration attributes can appear in any order in the <registration> element.
(Optional) A Boolean value indicating whether the script component can be instantiated remotely using DCOM. For details, see Creating Remote Instances of Script Components in the topic "Using a Script Component in an Application."


After a script component is created, it can be registered using a program such as Regsvr32.exe, which reads the information in the <registration> element and writes it into the computer's Windows Registry. For example, a script component can be registered this way:

regsvr32 file:\\myserver\MyComponent.wsc
Note   A <registration> element is not required in all cases. For example, a script component that implements the DHTML Behaviors interface handler in Microsoft® Internet Explorer 5.0 does not need to be registered, because Internet Explorer registers the behaviors as they are detected on the page. For details about registration requirements, see the documentation for the interface handler you are implementing and note also which host the script component will be used in.

If you do not include class ID information, the registration program assigns a class ID to your script component at the time it is registered. However, the script component will have a different class ID everywhere it is registered. It is highly recommended that you provide a class ID for the script component yourself, to ensure that your script component has the same class ID on all computers on which it is registered.

Allowing the registration program to create a class ID can cause problems if you use the script component with development tools that store class IDs. If the registration creates a new class ID each time, it will not match the the ID stored by the application.

You can optionally run scripts when a script component is registered and unregistered. To do so, include a <script> element within the <registration> element. To run script during registration, write a register( ) function. To run script when the script component has been unregistered, include an unregister( ) function.


The following shows a typical <registration> element that includes both a prog ID and a class ID.

   description="My Test Component"

The following registration element allows the script component to be instantiated via DCOM:

   description="My Test Component"

The following example shows a <registration> element that includes script to be run when the script component is registered and unregistered.

Note   A CDATA section is required to make the script in the <script> element opaque. For details, see Script Component Files and XML Conformance.
   description="My Test Component">

   <script language="VBScript">
      Function register()
         MsgBox "Component 'My Test Component' registered."
      End Function
      Function unregister()
         MsgBox "Component 'My Test Component' unregistered."
      End Function

See Also

Creating Registration Information | Registering a Script Component