From 8b42562aec47d2067c608ecf5d39b315d1ce813e Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Mon, 8 May 2017 22:12:39 -0700 Subject: [PATCH] Alter how Launch Program with Profile works --- DS4Windows/DS4Control/ScpUtil.cs | 34 +++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/DS4Windows/DS4Control/ScpUtil.cs b/DS4Windows/DS4Control/ScpUtil.cs index 34ebe0c..078631a 100644 --- a/DS4Windows/DS4Control/ScpUtil.cs +++ b/DS4Windows/DS4Control/ScpUtil.cs @@ -1970,13 +1970,45 @@ namespace DS4Windows int shiftM = 0; if (m_Xdoc.SelectSingleNode("/" + rootname + "/ShiftModifier") != null) int.TryParse(m_Xdoc.SelectSingleNode("/" + rootname + "/ShiftModifier").InnerText, out shiftM); + try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/LaunchProgram"); launchProgram[device] = Item.InnerText; - if (launchprogram == true && launchProgram[device] != string.Empty) System.Diagnostics.Process.Start(launchProgram[device]); } catch { launchProgram[device] = string.Empty; missingSetting = true; } + + if (launchprogram == true && launchProgram[device] != string.Empty) + { + string programPath = launchProgram[device]; + System.Diagnostics.Process[] localAll = System.Diagnostics.Process.GetProcesses(); + bool procFound = false; + for (int procInd = 0, procsLen = localAll.Length; !procFound && procInd < procsLen; procInd++) + { + try + { + string temp = localAll[procInd].MainModule.FileName; + if (temp == programPath) + { + procFound = true; + } + } + // Ignore any process for which this information + // is not exposed + catch { } + } + + if (!procFound) + { + System.Diagnostics.Process tempProcess = new System.Diagnostics.Process(); + tempProcess.StartInfo.FileName = programPath; + tempProcess.StartInfo.WorkingDirectory = new FileInfo(programPath).Directory.ToString(); + //tempProcess.StartInfo.UseShellExecute = false; + try { tempProcess.Start(); } + catch { } + } + } + try { Item = m_Xdoc.SelectSingleNode("/" + rootname + "/DinputOnly");