/**
 * +----------------------------------------------------------------------------+
 * |                          Jeffrey M. Hunter                                 |
 * |                      jhunter@idevelopment.info                             |
 * |                         www.idevelopment.info                              |
 * |----------------------------------------------------------------------------|
 * |      Copyright (c) 1998-2011 Jeffrey M. Hunter. All rights reserved.       |
 * |----------------------------------------------------------------------------|
 * | FILE       : ListShares.js                                                 |
 * | CLASS      : Networking                                                    |
 * | PURPOSE    : Enumerate through all connected (network shared) drives.      |
 * | PARAMETERS : None                                                          |
 * | USAGE      : cscript ListShares.js //NoLogo                                |
 * | NOTE       : As with any code, ensure to test this script in a development |
 * |              environment before attempting to run it in production.        |
 * +----------------------------------------------------------------------------+
 **/


function main() {

    var objNetwork;
    var objMappedDrives, objMappedDrivesIterator;
    var strDrive, strDriveShare;

    objNetwork = new ActiveXObject("WScript.Network");

    objMappedDrives = objNetwork.EnumNetworkDrives();
    objMappedDrivesIterator = new Enumerator (objMappedDrives);
    
    for (; !objMappedDrivesIterator.atEnd(); objMappedDrivesIterator.moveNext() ) {
        strDrive = objMappedDrivesIterator.item();
        objMappedDrivesIterator.moveNext();
        strDriveShare = objMappedDrivesIterator.item();
        WScript.Echo(strDrive + " is connected to " +  strDriveShare);
    }
    
    objNetwork = null;

}

main();
WScript.Quit(0);
    

