我会说 Damien_The_Unbeliever 是对的。我只是将 blat 从 windows 目录移动到 c:/blat/blat.exe 并且它工作正常。为了完整性,请原谅我之前的废话,废话,废话,失败的命令是
static void ExecuteCommandSync(object command)
{
try
{
System.Diagnostics.ProcessStartInfo procStartInfo =
new System.Diagnostics.ProcessStartInfo(@"C:/Windows/System32/blat.exe", "-server 127.0.0.1:1099 -subject Hello -to myname@gmail.com -body theBody -p gmailsmtp -from myname@gmail.com");
System.Diagnostics.Process process;
procStartInfo.RedirectStandardOutput = true;
procStartInfo.RedirectStandardError = true;
procStartInfo.UseShellExecute = false;
procStartInfo.CreateNoWindow = true;
process = System.Diagnostics.Process.Start(procStartInfo);
process.WaitForExit();
var output = process.StandardOutput.ReadToEnd();
var error = process.StandardError.ReadToEnd();
var exitCode = process.ExitCode;
Console.WriteLine(error);
process.Close();
}
catch (Exception objException)
{
// to be logged
}
}
cmd.exe /cc:/Windows/System32/blat.exe 的变体同样失败。非常感谢您的帮助