<commit_before>var Q = require('q');
var fs = require('fs');
var childProcess = require('child_process');
var spawn = childProcess.spawn;
var spawnSync = childProcess.spawnSync;

function deleteRdpCredentials(ip) {
  return spawnSync('cmdkey.exe', ['/delete:TERMSRV/' + ip]);
}

function storeRdpCredentials(ip, username, password) {
  // when saving credentials, ignore the IP or weird things will happen when multiple OSs are accessed via RDP
  ip = ip.replace(/:.*/g, '');
  return spawnSync('cmdkey.exe', ['/generic:TERMSRV/' + ip, '/user:' + username, '/pass:' + password]);
}

function deleteRdpFile(filePath) {
  fs.unlinkSync(filePath);
}

function connect(config, filePath) {
  var deferred = Q.defer();
  var proc = spawn('mstsc.exe', [filePath, '/admin', '/control', '/v', config.address]);
  // when the process is closed, return the control to the pipe
  proc.on('exit', function() {
    deferred.resolve(true);
  });
  // force the disconnection when the promise is resolved
  deferred.promise.fail(function() {
    if (!proc.killed) {
      proc.kill();
    }
  });
  return deferred;
}

function cleanup(config, filePath) {
  if (typeof(config.deleteCredentialsAfter) === 'undefined' || config.deleteCredentialsAfter === true) {
    deleteRdpCredentials(config.address);
  }
  deleteRdpFile(filePath);
  return true;<commit_msg>removed the '/control' parameter for the mstsc command https://technet.microsoft.com/de-de/library/cc753907%28v=ws.10%29.aspx<commit_after>var Q = require('q');
var fs = require('fs');
var childProcess = require('child_process');
var spawn = childProcess.spawn;
var spawnSync = childProcess.spawnSync;

function deleteRdpCredentials(ip) {
  return spawnSync('cmdkey.exe', ['/delete:TERMSRV/' + ip]);
}

function storeRdpCredentials(ip, username, password) {
  // when saving credentials, ignore the IP or weird things will happen when multiple OSs are accessed via RDP
  ip = ip.replace(/:.*/g, '');
  return spawnSync('cmdkey.exe', ['/generic:TERMSRV/' + ip, '/user:' + username, '/pass:' + password]);
}

function deleteRdpFile(filePath) {
  fs.unlinkSync(filePath);
}

function connect(config, filePath) {
  var deferred = Q.defer();
  var proc = spawn('mstsc.exe', [filePath, '/admin', '/v', config.address]);
  // when the process is closed, return the control to the pipe
  proc.on('exit', function() {
    deferred.resolve(true);
  });
  // force the disconnection when the promise is resolved
  deferred.promise.fail(function() {
    if (!proc.killed) {
      proc.kill();
    }
  });
  return deferred;
}

function cleanup(config, filePath) {
  if (typeof(config.deleteCredentialsAfter) === 'undefined' || config.deleteCredentialsAfter === true) {
    deleteRdpCredentials(config.address);
  }
  deleteRdpFile(filePath);
  return true;
{'fraction_non_alphanumeric': 0.15315638450502153, 'fraction_numerical': 0.00430416068866571, 'mean_word_length': 4.511857707509882, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5479551', 'n_tokens_mistral': 885, 'n_tokens_neox': 876, 'n_words': 226}