is this what you are looking for?
//some useful settings, edit where appropriate
var destenationFolder = "E:\\LAPS\\TestFiles"; //where to safe the file
var fileName = null; //empty as we're generating these, if you want to specify a single name, do it here
var slctdonly = false; //set to true of you only want the selected layercomps exported
//list active documents
var documentList = app.documents;
for( var i = 0; i<documentList.length; i++ ){
app.activeDocument = documentList[i];
theName = (fileName == null)? app.activeDocument.name.replace('.psd',''):fileName;
execLC2F( theName, destenationFolder, slctdonly );
}
function execLC2F( theFileName, theDestenationFolder, onlySelected ){
var LC2F = stringIDToTypeID( "cf34b502-2013-4d07-8431-1dfd634ee0cd" );
var desc324 = new ActionDescriptor();
var idMsge = charIDToTypeID( "Msge" );
desc324.putString( idMsge, """Layer Comps To Files action settings""" );
var iddestination = stringIDToTypeID( "destination" );
desc324.putString( iddestination, theDestenationFolder );
var idfileNamePrefix = stringIDToTypeID( "fileNamePrefix" );
desc324.putString( idfileNamePrefix, theFileName );
var idselectionOnly = stringIDToTypeID( "selectionOnly" );
desc324.putBoolean( idselectionOnly, onlySelected ); //<----
executeAction( LC2F, desc324, DialogModes.NO );
}