Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize

item Method (Windows Scripting - JScript)

 

Returns the current item in the collection.

enumObj.item() 

The required enumObj reference is any Enumerator object.

The item method returns the current item. If the collection is empty or the current item is undefined, it returns undefined.

In following code, the item method is used to return a member of the Drives collection.

function ShowDrives()
{
    var s = "";
    var bytesPerGB = 1024 * 1024 * 1024;

    var fso = new ActiveXObject("Scripting.FileSystemObject");
    var e = new Enumerator(fso.Drives);

    e.moveFirst();
    while (e.atEnd() == false)
    {
        var drv = e.item();

        s += drv.Path + " - ";

        if (drv.IsReady)
        {
            var freeGB = drv.FreeSpace / bytesPerGB;
            var totalGB = drv.TotalSize / bytesPerGB;

            s += freeGB.toFixed(3) + " GB free of ";
            s += totalGB.toFixed(3) + " GB";
        }
        else
        {
            s += "Not Ready";
        }

        s += "<br />";

        e.moveNext();
    }
    return(s);
}

Change History

Date

History

Reason

September 2009

Modified example.

Information enhancement.

Show:
© 2015 Microsoft