S
sjoshi
Hi All
I'm trying to use the Process/ProcessStartInfo class to use
sysinternals psexec tool to run a remote command but I'm unable to get
the output. The same command thru a DOS window runs fine on a remote
server.
The code is very simple...
_logger.Debug(string.Format("Filename: {0} Args: {1}", pathToExe,
args));
pc = new Process();
pc.StartInfo.FileName = pathToExe;
pc.StartInfo.Arguments = args;
pc.StartInfo.CreateNoWindow = true;
pc.StartInfo.UseShellExecute = false;
pc.StartInfo.RedirectStandardOutput = true;
if (pc.Start())
{
output = pc.StandardOutput.ReadToEnd();
pc.WaitForExit(20 * 1000);
}
return output;
But the process seems to wait forever. I even tried getting the log of
the parameters namely pathToExe and args and then running it manually
and that ran fine.
Any hints are appreciated.
thanks
Sunit
I'm trying to use the Process/ProcessStartInfo class to use
sysinternals psexec tool to run a remote command but I'm unable to get
the output. The same command thru a DOS window runs fine on a remote
server.
The code is very simple...
_logger.Debug(string.Format("Filename: {0} Args: {1}", pathToExe,
args));
pc = new Process();
pc.StartInfo.FileName = pathToExe;
pc.StartInfo.Arguments = args;
pc.StartInfo.CreateNoWindow = true;
pc.StartInfo.UseShellExecute = false;
pc.StartInfo.RedirectStandardOutput = true;
if (pc.Start())
{
output = pc.StandardOutput.ReadToEnd();
pc.WaitForExit(20 * 1000);
}
return output;
But the process seems to wait forever. I even tried getting the log of
the parameters namely pathToExe and args and then running it manually
and that ran fine.
Any hints are appreciated.
thanks
Sunit