Chat now with support
Chat with Support

InTrust 11.3.2 - Customization Kit

ActiveXObject

This class lets you use COM automation in scripts. It has the same functionality as the comparable class in Windows Script Host.

You can create ActiveX objects as follows:

// Method 1:
var p = new ActiveXObject("{CB3DF937-8DBB-4130-8A11-D47E12F61315}");
// Here, the argument is the CLSID
// of the object you want to create.
//Method 2:
var p = new ActiveXObject("Scripting.FileSystemObject");
// ProgID is the argument.

After you have created the object, you can access its methods, read and write its properties.

In case of error, an exception is generated, represented by an ActiveXError object. This object class contains the following fields:

  • number
    Error code

  • text
    Message that corresponds to the error code

  • description
    An optional description of the error

In the following example, possible exceptions are caught:

try
{
var p = new ActiveXObject("SomeCOMObject.ProgID");
p.method();
}
catch( err )
{
      print( "Error: " + err );
}

File

NAME

TYPE

DESCRIPTION

OpenAsTextStream([iomode[, crmode[, format]]])

method

Returns a new TextStream object. See FileSystemObject.OpenTextFile for details.

Delete()

method

Deletes the file.

Name

property

Returns the name of the file.

Path

property

Returns the full path to the file.

DateLastModified

property

Returns the date and time that the file or folder was last modified.

Size

property

Returns the size of the file in bytes.

FileSystemObject

NAME

TYPE

DESCRIPTION

OpenTextFile(absolute_path[, iomode[, crmode[, format]]])

method

Opens the specified file and returns a TextStream object that can be used to read from the file. Requires the absolute path to the file as a parameter.

  • The iomode parameter can be one of the constants returned by the properties of the object, which are accessed by the AccessMode static property.
  • The crmode parameter can be one of the constants returned by the properties of the object, which are accessed by the CreationDisposition static property.
  • The format parameter specifies the encoding of the file. This can be one of the following string values: "MBCS", "UTF-8", "UTF-16", "UTF-16LE", "UTF-16BE", "Auto". See the next table for details.

GetFile(path)

method

Returns a File object representing the file with the specified path.

GetFolder(path)

method

Returns a Folder object representing the folder with the specified path.

DeleteFile(path)

method

Deletes the specified file.

CreationDisposition

static property

Returns an object with the OpenExisting read-only property.

AccessMode

static property

Returns an object with the ForReading read-only property.

 

Use "MBCS", "UTF-8", "UTF-16LE" or "UTF-16BE" only if you know for certain what file encoding is used. Otherwise, use "UTF-16" (platform specific) or "Auto". This is the default, which uses the byte order mask (BOM) to detect file encoding.

The following table shows how the encoding is determined from the BOM and explicitly specified format parameter.

 

"MBCS"

"UTF-8"

"UTF-16"

"UTF-16LE"

"UTF-16BE"

"AUTO"

<NONE>

MBCS

UTF-8

UTF-16 p. s.

UTF-16LE

UTF-16BE

MBCS

UTF-8

MBCS

UTF-8

UTF-16 p. s.

UTF-16LE

UTF-16BE

UTF-8

UTF-16LE

MBCS

UTF-8

UTF-16LE

UTF-16LE

Error

UTF-16LE

UTF-16BE

MBCS

UTF-8

UTF-16BE

Error

UTF-16BE

UTF-16BE

*In the table "p. s." stands for platform-specific byte order.

Folder

NAME

TYPE

DESCRIPTION

Files

array of File objects

Provides a list of files contained within the folder.

SubFolders

array of Folder objects

Provides a list of folders contained within a folder.

Name

property

Returns the name of the folder.

Path

property

Returns the full path to the folder.

Related Documents

The document was helpful.

Select Rating

I easily found the information I needed.

Select Rating