function ListFiles(fc) {
    var enumFiles;

    enumFiles = new Enumerator (fc);
    for (; !enumFiles.atEnd(); enumFiles.moveNext()) {
        WScript.Echo (enumFiles.item().Path + "\\" + enumFiles.item().Name);
    }
}

function ListDirectory (strRootDir) {
    var enumFolders;
    var oFolder;
    var fso;
    
    // Get FileSystemObject Object
    fso = new ActiveXObject("Scripting.FileSystemObject");

    oFolder = fso.GetFolder(strRootDir);
    
    ListFiles(oFolder.files);
    
    enumFolders = new Enumerator (oFolder.SubFolders);
    for (; !enumFolders.atEnd(); enumFolders.moveNext()) {
        ListDirectory(strRootDir + "\\" + enumFolders.item().name);
    }
}


function GetDirectoryFiles (strRootDir, bIsRecursive) {
    var enumFolders;
    var fcSubFiles;
    var enumFiles;
    var arrFiles;
    var oFolder;
    var fso;
    
    // Get FileSystemObject Object
    fso = new ActiveXObject("Scripting.FileSystemObject");


    oFolder = fso.GetFolder(strRootDir);
    arrFiles = new Array();
    
    enumFiles = new Enumerator(oFolder.files);

    for (; !enumFiles.atEnd(); enumFiles.moveNext()) {
        arrFiles.push (enumFiles.item().Path);
    }

    if (bIsRecursive) {
        enumFolders = new Enumerator (oFolder.SubFolders);
        for (; !enumFolders.atEnd(); enumFolders.moveNext()) {
            enumFiles = new Enumerator(GetDirectoryFiles(strRootDir + "\\" + enumFolders.item().name, true));

            for (; !enumFiles.atEnd(); enumFiles.moveNext()) {
                arrFiles.push (enumFiles.item());
            }
        }
    }

    return (arrFiles);
}