Skip to content

Commit

Permalink
Launcher now has the ability to restart steam upon 'first' install
Browse files Browse the repository at this point in the history
  • Loading branch information
MaelElseware committed Sep 2, 2018
1 parent bc75172 commit 1791fa3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
13 changes: 13 additions & 0 deletions NaturalLauncher/Launcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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())
Expand Down
6 changes: 6 additions & 0 deletions NaturalLauncher/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 1791fa3

Please sign in to comment.