いつもお世話になっております。
C#で、shell実行し、標準出力された結果をリダイレクトして、
戻り値として取得するプログラムを作成したのですが、
ビルドしたプログラムを別のPCで実行すると、
戻り値がうまく取得できません。
考えられる原因など、何かご存知の方がいらっしゃいましたら、
ご教示願えませんでしょうか。
■アプリケーションの基本情報
フレームワーク : .NET Framwork4.5.2
IDE : Visual Studio 2017
プラットフォーム : x64
■戻り値が取得できないPCの環境
OS:Windows7 Pro 64bit
CPU:Core i5 4590 3.3GHz
C#
1public string execute(string args) 2{ 3 System.Diagnostics.Process p = new System.Diagnostics.Process(); 4 5 p.StartInfo.FileName = exe_path; 6 p.StartInfo.UseShellExecute = false; 7 p.StartInfo.RedirectStandardOutput = true; 8 p.StartInfo.RedirectStandardInput = false; 9 p.StartInfo.CreateNoWindow = true; 10 p.StartInfo.Arguments = args; 11 p.Start(); 12 13 string results = p.StandardOutput.ReadToEnd(); 14 15 p.WaitForExit(); 16 p.Close(); 17 18 return results; 19} 20
宜しくお願い申し上げます。
「うまく取得できない」とおっしゃるのは、例外が発生するわけではなく、戻ってきたresultsがおかしな値であるということでしょうか。そのあたりをお示しいただくと手掛かりになるかもしれません。

回答3件
あなたの回答
tips
プレビュー