プロセスを使用してc#.netでexeファイルを実行しようとしています。Windowsサービスでプロセスが起動しない
System.InvalidOperationException:このオブジェクトに関連付けられているプロセスはありません。 System.Diagnostics.ProcessでSystem.Diagnostics.Process.GetProcessHandleでSystem.Diagnostics.Process.EnsureState(ステート状態) でSystem.Diagnostics.Process.EnsureState(ステート状態) (のInt32アクセス、ブールthrowIfExited) で 。 WaitForExit(のInt32ミリ秒)VideoHandlingWinService.VideoHandlingService.VideoHandling(文字列VideoNameでVideoHandlingWinService.VideoHandlingService.ConvertVideoToFlvでSystem.Diagnostics.Process.WaitForExit() (文字列関数savepath、文字WithOutExt、文字INPUTFILE、ストリングSPATH、のInt32 VideoQueueId) において、文字列SavePath、文字列InputFile、文字列WithOutExt、文字列spath、Int32 VideoQueueId、String VideoDescription、Int32 RegisteredUserId、Int32 CategoryId、String VideoTitle)at VideoHandlingWinService.V次のようにプロセスを開始するVideoHandlingWinService.VideoHandlingService.OnStart(文字列[] args)をでideoHandlingService.StartHandlingVideo()
私のコードは次のとおりです。
Process proc = new Process();
string spath = AppDomain.CurrentDomain.BaseDirectory.ToString();
try
{
proc.StartInfo.FileName = spath + "\\ffmpeg\\ffmpeg.exe";
proc.StartInfo.Arguments = FilArgs;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.CreateNoWindow = false;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.RedirectStandardError = true;
proc.Start();
string StdOutVideo = proc.StandardOutput.ReadToEnd();
string StdErrVideo = proc.StandardError.ReadToEnd();
}
catch { }
finally
{
proc.WaitForExit();
proc.Close();
}
いずれこれを行う方法を教えてくださいWindowsサービス内。また、私はローカルアカウントとしてWindowsサービスを実行しており、exeの許可の問題がないことを願っています。私はエラーが
proc.WaitForExit();
で起こると考え
空のキャッチブロックがあります。それを削除するか、そこにログインして実際に何が起こっているかを確認してください。 –
多分あなたの空のキャッチが例外を飲み込み、プロセスが決して実行されなかったことを意味し、エラーメッセージを説明します。 – wj32