ASP.NET Web サイトから古い .NET アプリケーションを実行しようとしています。WebとStackoverflowを読んだ後(同様の問題について)、次のコードにたどり着きました。問題は、常にエラー コードが表示されることです (テスト目的のためだけに管理者アカウントを使用しています)。exeを手動で実行すると、問題なく動作します。
private void Execute(string sPath)
{
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.UserName = "administrador";
string pass = ".............";
System.Security.SecureString secret = new System.Security.SecureString();
foreach (char c in pass) secret.AppendChar(c);
proc.StartInfo.Password = secret;
proc.StartInfo.WorkingDirectory = ConfigurationManager.AppSettings["WORKINGDIRECTORY"].ToString();
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.RedirectStandardError = true;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.FileName = sPath;
proc.Start();
proc.WaitForExit();
string result = proc.StandardOutput.ReadToEnd();
Response.Write(result + " - " + proc.ExitCode);
proc.Close();
}
}
私が得る終了コードは次のとおりです: -1066598274 結果変数は空です。IIS 7.0 で Windows 2008 を使用していますが、例外はスローされません。
前もって感謝します、
エセキエル