やりたいこと
Unityで作成したEXEから指定のBatを起動したいです。
問題点
Unityでスタンドアロン版のExeを作成して起動するとエラーになる
UnityEditorのメニューバーからはエラーなく実行できます。
何が問題なんでしょうか
Error
[ERROR]エラー:The Process object must have the UseShellExecute property set to false in order to redirect IO streams.
作成コード
C#
//batFilePath=.../_Data/StreamingAssets/callText.bat private static void TEST(string batFilePath) { Debug.LogError("[TEST] Start"); try { var startInfo = new System.Diagnostics.ProcessStartInfo() { FileName = batFilePath, UseShellExecute = true, ErrorDialog = true, RedirectStandardOutput = true, RedirectStandardError = true, Verb = "RunAs", }; using (var process = System.Diagnostics.Process.Start(startInfo)) { var so = process.StandardOutput.ReadToEnd(); var se = process.StandardError.ReadToEnd(); process.WaitForExit(); Debug.LogError("so" + so); Debug.LogError("[TEST] ------"); Debug.LogError("se" + se); } } catch (Exception ex) { Debug.LogError("エラー:" + ex.Message); } Debug.LogError("[TEST] Exit"); }
Batファイル
@echo off call notepad.exe pause
まだ回答がついていません
会員登録して回答してみよう