Skip to content

Commit

Permalink
Moved ds4updater launch code to VM
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryochan7 committed Jul 30, 2022
1 parent d509ea0 commit ea2e5ff
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 22 deletions.
23 changes: 1 addition & 22 deletions DS4Windows/DS4Forms/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,28 +213,7 @@ private void Check_Version(bool showstatus = false)

if (launch)
{
using (Process p = new Process())
{
p.StartInfo.FileName = Path.Combine(Global.exedirpath, "DS4Updater.exe");
bool isAdmin = Global.IsAdministrator();
List<string> argList = new List<string>();
argList.Add("-autolaunch");
if (!isAdmin)
{
argList.Add("-user");
}

// Specify current exe to have DS4Updater launch
argList.Add("--launchExe");
argList.Add(Global.exeFileName);

p.StartInfo.Arguments = string.Join(" ", argList);
if (Global.AdminNeeded())
p.StartInfo.Verb = "runas";

try { launch = p.Start(); }
catch (InvalidOperationException) { }
}
launch = mainWinVM.LauchDS4Updater();
}

if (launch)
Expand Down
30 changes: 30 additions & 0 deletions DS4Windows/DS4Forms/ViewModels/MainWindowsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Threading.Tasks;
using HttpProgress;
using DS4Windows;
using System.Collections.Generic;

namespace DS4WinWPF.DS4Forms.ViewModels
{
Expand Down Expand Up @@ -127,5 +128,34 @@ public void CheckDrivers()
catch { }
}
}

public bool LauchDS4Updater()
{
bool launch = false;
using (Process p = new Process())
{
p.StartInfo.FileName = Path.Combine(Global.exedirpath, "DS4Updater.exe");
bool isAdmin = Global.IsAdministrator();
List<string> argList = new List<string>();
argList.Add("-autolaunch");
if (!isAdmin)
{
argList.Add("-user");
}

// Specify current exe to have DS4Updater launch
argList.Add("--launchExe");
argList.Add(Global.exeFileName);

p.StartInfo.Arguments = string.Join(" ", argList);
if (Global.AdminNeeded())
p.StartInfo.Verb = "runas";

try { launch = p.Start(); }
catch (InvalidOperationException) { }
}

return launch;
}
}
}

0 comments on commit ea2e5ff

Please sign in to comment.