From 1791fa31c69b0bffa2169389f45f3e4ca8d1bb64 Mon Sep 17 00:00:00 2001 From: Mael-fixe Date: Sun, 2 Sep 2018 16:28:07 +0200 Subject: [PATCH] Launcher now has the ability to restart steam upon 'first' install --- NaturalLauncher/Launcher.cs | 13 +++++++++++++ NaturalLauncher/MainWindow.xaml.cs | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/NaturalLauncher/Launcher.cs b/NaturalLauncher/Launcher.cs index 3d6d71f..4f76a0d 100644 --- a/NaturalLauncher/Launcher.cs +++ b/NaturalLauncher/Launcher.cs @@ -44,6 +44,8 @@ class Launcher public static string configName = "Launcher.xml"; public static bool keepLauncherAlive = true; + public static bool restartSteam = false; // used at the end of the verify process + public static DateTime LAUNCHTIME = System.DateTime.UtcNow; public static string discordCustomStatus = "Currently In The Launcher"; @@ -130,6 +132,17 @@ public static void LaunchWebsite(string Url) Process.Start(Url); } + public static void RestartSteam() + { + string strCmdText; + strCmdText = "/c taskkill /f /IM \"steam.exe\" "; + System.Diagnostics.Process.Start("CMD.exe", strCmdText); // kill steam + System.Threading.Thread.Sleep(1000); // wait one sec + strCmdText = "/c start steam:"; + System.Diagnostics.Process.Start("CMD.exe", strCmdText); // start steam + + } + public static void RefreshInternetPageAsync(string whichPage) { using (var webClient = new WebClient()) diff --git a/NaturalLauncher/MainWindow.xaml.cs b/NaturalLauncher/MainWindow.xaml.cs index d98434d..d365a85 100644 --- a/NaturalLauncher/MainWindow.xaml.cs +++ b/NaturalLauncher/MainWindow.xaml.cs @@ -213,6 +213,7 @@ private void Check_Version() MessageBoxResult AlertBox = System.Windows.MessageBox.Show("Please verify the installation" + Environment.NewLine + "This message will show up if this is the first time you launch this software" , "Alert", MessageBoxButton.OK, MessageBoxImage.Exclamation); //not true anymore + Launcher.restartSteam = true; SettingButton.IsEnabled = false; IsVerification = false; } @@ -419,6 +420,11 @@ public void UpdateGame_RunWorkerCompleted(object sender, RunWorkerCompletedEvent else { ProgressLabel.Content = "Up to date !"; + if (Launcher.restartSteam) + { + Launcher.RestartSteam(); + UpdateLog.WriteLine(Util.GetShortTimeString() + "Restarting Steam"); + } StartButton.Content = "Play"; UpdateLog.WriteLine(Util.GetShortTimeString() + "Completed the update or verify work"); TaskbarItemInfo.ProgressValue = 0;