diff --git a/EverythingToolbar/Data/SearchResult.cs b/EverythingToolbar/Data/SearchResult.cs index ebce03484..c878370a3 100644 --- a/EverythingToolbar/Data/SearchResult.cs +++ b/EverythingToolbar/Data/SearchResult.cs @@ -35,7 +35,11 @@ public void Open() { try { - Process.Start(FullPathAndFileName); + Process.Start(new ProcessStartInfo(FullPathAndFileName) + { + UseShellExecute = true, + WorkingDirectory = IsFile ? Path : FullPathAndFileName + }); EverythingSearch.Instance.IncrementRunCount(FullPathAndFileName); } catch (Exception e) diff --git a/EverythingToolbar/Helpers/ShellUtils.cs b/EverythingToolbar/Helpers/ShellUtils.cs index a71f80e40..e0589de2d 100644 --- a/EverythingToolbar/Helpers/ShellUtils.cs +++ b/EverythingToolbar/Helpers/ShellUtils.cs @@ -92,7 +92,7 @@ private static extern bool CreateProcess( [In] ref STARTUPINFO lpStartupInfo, out PROCESS_INFORMATION lpProcessInformation); - public static void CreateProcessFromCommandLine(string commandLine) + public static void CreateProcessFromCommandLine(string commandLine, string workingDirectory = null) { var si = new STARTUPINFO(); var pi = new PROCESS_INFORMATION(); @@ -105,7 +105,7 @@ public static void CreateProcessFromCommandLine(string commandLine) false, 0, IntPtr.Zero, - null, + workingDirectory, ref si, out pi); } diff --git a/EverythingToolbar/Rules.xaml.cs b/EverythingToolbar/Rules.xaml.cs index cbb35e40d..33770fa6c 100644 --- a/EverythingToolbar/Rules.xaml.cs +++ b/EverythingToolbar/Rules.xaml.cs @@ -185,7 +185,7 @@ public static bool HandleRule(SearchResult searchResult, string command="") command = command.Replace("%path%", "\"" + searchResult.Path + "\""); try { - ShellUtils.CreateProcessFromCommandLine(command); + ShellUtils.CreateProcessFromCommandLine(command, searchResult.Path); return true; } catch(Win32Exception)