checkArgument(cmd.getArguments().size() > 0, "Cannot execute empty command line");
final String obfuscatedCmd = cmd.toCommandLine(os, true);
logger.info("Starting command [{}] on [{}]", obfuscatedCmd, this);
final CmdLine winrsCmd = new CmdLine();
winrsCmd.addArgument("winrs");
winrsCmd.addArgument("-remote:" + address + ":" + port);
winrsCmd.addArgument("-username:" + username);
winrsCmd.addPassword("-password:" + password);
if (workingDirectory != null) {
winrsCmd.addArgument("-directory:" + workingDirectory.getPath());
}
if (options.getBoolean(WINRS_NOECHO, WINRS_NOECHO_DEFAULT)) {
winrsCmd.addArgument("-noecho");
}
if (options.getBoolean(WINRS_NOPROFILE, WINRS_NOPROFILE_DEFAULT)) {
winrsCmd.addArgument("-noprofile");
}
if (options.getBoolean(WINRS_ALLOW_DELEGATE, DEFAULT_WINRS_ALLOW_DELEGATE)) {
winrsCmd.addArgument("-allowdelegate");
}
if (options.getBoolean(WINRS_COMPRESSION, WINRS_COMPRESSION_DEFAULT)) {
winrsCmd.addArgument("-compression");
}
if (options.getBoolean(WINRS_UNENCRYPTED, WINRS_UNENCRYPTED_DEFAULT)) {
winrsCmd.addArgument("-unencrypted");
}
if (options.getBoolean(WINRM_ENABLE_HTTPS, WINRM_ENABLE_HTTPS_DEFAULT)) {
winrsCmd.addArgument("-usessl");
}
winrsCmd.add(cmd.getArguments());
return winrsProxyConnection.startProcess(winrsCmd);
}