<object> Element (Windows Script Host)

Defines objects in Windows Script (.wsf) files that can be referenced by a script.

                      <object id="objID" {classid="clsid:GUID" | progid="progID"} [events="hookevents"] />


Required. A name that references the object in your script. Object ID values must begin with a letter and can include letters, digits, and underscores (_). The object ID must be unique throughout the scope of the Windows Script file.


Required unless progID is defined. The class ID (GUID) of the object.


Required unless GUID is defined. Program ID of the object, which can be specified as an alternative to the class ID.


Optional. A value (either "true" or "false") that determines if you can hook events from the object. By default, hookevents is false. If the attribute is true, you can connect to any events the object may fire. You must add an event handler for each event that is to be handled.

The <object> element provides a way to expose objects globally for use in scripting within the Windows Script file without using functions such as CreateObject(). Using an <object> element makes the object available with global scope and enables scripting tools to provide statement completion for the object's members.

You must specify either a classid or a progid.

<object id="fso" progid="Scripting.FileSystemObject"/>
<script language="JScript">

    var file = fso.CreateTextFile("c:\\testfile.txt", true);
    file.WriteLine("This is a test.");