d

List Shares on a Host

/**
 *    Script:   listShares.js
 *    Purpose:  Lists shares on a specified server is a domain.
 *    Author:   Daren Thiel
 *    Date:     4 Nov 2000
 *    Web:      http://www.winscripter.com
 **/

WScript.Echo( listShares( "yourdomain", "someserver" ) ); 
 
function listShares( domain, host )
{
    var list = "Shares on \\\\" + domain + "\\" + host + "\n";
    list += "=======================================\n";
    try 
    {
        var fileservice = GetObject( "WinNT://" + domain + "/" + host + "/Lanmanserver" );
    
        var e = new Enumerator( fileservice );
        for( ; !e.atEnd(); e.moveNext() )
        {
            var share = e.item();
            list += share.Name + "\n";
        }
    } 
    catch( e ) 
    {
        list += "Error: " + e.description;
    }
    return( list );
}