Skip to content

Commit

Permalink
Use process directory as working directory (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
srwi committed Feb 6, 2021
1 parent 345bebf commit fd2af3f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion EverythingToolbar/Data/SearchResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions EverythingToolbar/Helpers/ShellUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -105,7 +105,7 @@ public static void CreateProcessFromCommandLine(string commandLine)
false,
0,
IntPtr.Zero,
null,
workingDirectory,
ref si,
out pi);
}
Expand Down
2 changes: 1 addition & 1 deletion EverythingToolbar/Rules.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit fd2af3f

Please sign in to comment.