var childProcess = require('child_process');
var options = {maxBuffer:100*1024, encoding:'utf8', timeout:5000};
var child = childProcess.exec('dir /B', options, 
                              function (error, stdout, stderr) {
  if (error) {
    console.log(error.stack);
    console.log('Kod błędu: '+error.code);
    console.log('Sygnał błędu: '+error.signal);
  }
  console.log('Wyniki: \n' + stdout);
  if (stderr.length){
    console.log('Błędy: ' + stderr);
  }
});
child.on('exit', function (code) {
  console.log('Zakończono z kodem: '+code);
});