public bool PSExec(string arguments) { Program = "psexec.exe"; execute(Px_Arguments(arguments)); StandardError = StandardError.Replace("\r\r", string.Empty).Replace("\r\nPsExec v1.98 - Execute processes remotely\r\nCopyright (C) 2001-2010 Mark Russinovich\r\nSysinternals - www.sysinternals.com\r\n", string.Empty).TrimEnd(null); if (StandardError.Contains("error code 0") == true) { return(true); } else { return(false); } }
public bool PSLoggedon(string arguments) { Program = "psloggedon.exe"; //Remotely enable required serice RemoteRegistry("start", IP, "remoteRegistry"); execute(Px_Arguments(arguments)); //Remotely disable required serice RemoteRegistry("stop", IP, "remoteRegistry"); if (StandardError.Contains("error code 0") == true) { return(true); } else { return(false); } }
protected override void ManageOutput() { //PAExec does not return standard error only Exit Codes. This interpuates the exit code and adds it to the standard error out. if (ExitCode < 0) { var errorData = string.Format("PAEXEC Error {0}: ", ExitCode); if (ExitCode == -1) { errorData += "internal error"; } if (ExitCode == -2) { errorData += "command line error"; } if (ExitCode == -3) { errorData += "failed to launch app (locally)"; } if (ExitCode == -4) { errorData += "failed to copy PAExec to remote (connection to ADMIN$ might have failed)"; } if (ExitCode == -5) { errorData += "connection to server taking too long (timeout)"; } if (ExitCode == -6) { errorData += "PAExec service could not be installed/started on remote server"; } if (ExitCode == -7) { errorData += "could not communicate with remote PAExec service"; } if (ExitCode == -8) { errorData += "failed to copy app to remote server"; } if (ExitCode == -9) { errorData += "failed to launch app (remotely)"; } if (ExitCode == -10) { errorData += "app was terminated after timeout expired"; } if (ExitCode == -11) { errorData += "forcibly stopped with Ctrl-C / Ctrl-Break"; } nlog.Error("[PAExec Arguments] {1}{0}[StandardError]{0}{2}{0}[StandardOutput]{0}{3}{0}[Exit Code] {4}", System.Environment.NewLine, StartInfo.Arguments, StandardError, StandardOutput, errorData); Log(log.Error, errorData); } else if (ExitCode > 0) { if (_arguments.Contains("RMDIR") && StandardError.Contains("The system cannot find the file specified")) { nlog.Warn("[PAExec Arguments] {1}{0}[StandardError]{0}{2}{0}[StandardOutput]{0}{3}{0}[Exit Code] {4}", System.Environment.NewLine, StartInfo.Arguments, StandardError, StandardOutput, ExitCode); Log(log.Warn, StandardError = string.Format("PAExec ran but command returned error {0} -- {1} --", ExitCode, StandardError.Trim())); } else { nlog.Error("[PAExec Arguments] {1}{0}[StandardError]{0}{2}{0}[StandardOutput]{0}{3}{0}[Exit Code] {4}", System.Environment.NewLine, StartInfo.Arguments, StandardError, StandardOutput, ExitCode); Log(log.Error, StandardError = string.Format("PAExec ran but command returned error {0} -- {1} --", ExitCode, StandardError.Trim())); } } }