diff --git a/UnityLauncherPro/MainWindow.xaml.cs b/UnityLauncherPro/MainWindow.xaml.cs index 5e1fd58..021eea7 100644 --- a/UnityLauncherPro/MainWindow.xaml.cs +++ b/UnityLauncherPro/MainWindow.xaml.cs @@ -1589,7 +1589,7 @@ private void ChkGetGitBranchRecursively_CheckedChanged(object sender, RoutedEven return; // dont run code on window init Settings.Default.searchGitFolderRecursivly = (bool)chkGetGitBranchRecursively.IsChecked; - Settings.Default.Save(); + Settings.Default.Save(); RefreshRecentProjects(); } @@ -3460,12 +3460,25 @@ private void menuInstallLastAPK_Click(object sender, RoutedEventArgs e) pars += $" && adb shell monkey -p {packageName} 1"; } - // TODO start cmd minimized - Tools.LaunchExe(cmd, pars); - // get apk name from path - var apkName = Path.GetFileName(playerPath); - if (chkStreamerMode.IsChecked == true) apkName = " (hidden in streamermode)"; - SetStatus("Installed APK:" + apkName); + //Tools.LaunchExe(cmd, pars); + var process = Tools.LaunchExe(cmd, pars, captureOutput: true); + var output = process.StandardOutput.ReadToEnd(); + var errorOutput = process.StandardError.ReadToEnd().Replace("\r", "").Replace("\n", ""); + + process.WaitForExit(); + + // Console.WriteLine(output); + if (!string.IsNullOrEmpty(errorOutput)) + { + SetStatus("Error installing APK: " + errorOutput); + } + else + { + // get apk name from path + var apkName = Path.GetFileName(playerPath); + if (chkStreamerMode.IsChecked == true) apkName = " (hidden in streamermode)"; + SetStatus("Installed APK:" + apkName); + } } private void txtWebglPort_TextChanged(object sender, TextChangedEventArgs e) diff --git a/UnityLauncherPro/Tools.cs b/UnityLauncherPro/Tools.cs index 1722f9d..9350ae7 100644 --- a/UnityLauncherPro/Tools.cs +++ b/UnityLauncherPro/Tools.cs @@ -488,7 +488,7 @@ public static bool LaunchExplorerSelectFile(string fileName) } // run any exe, return process - public static Process LaunchExe(string path, string param = null) + public static Process LaunchExe(string path, string param = null, bool captureOutput=false) { if (string.IsNullOrEmpty(path)) return null; @@ -510,6 +510,12 @@ public static Process LaunchExe(string path, string param = null) newProcess = new Process(); newProcess.StartInfo.FileName = "\"" + path + "\""; newProcess.StartInfo.Arguments = param; + if (captureOutput) + { + newProcess.StartInfo.RedirectStandardError = true; + newProcess.StartInfo.RedirectStandardOutput = true; + newProcess.StartInfo.UseShellExecute = false; + } newProcess.EnableRaisingEvents = true; // needed to get Exited event newProcess.Start(); }