From c62e230f380e9e645af4b74ec84f0bc4b70de539 Mon Sep 17 00:00:00 2001 From: Karthikeyan Vedi Date: Tue, 6 Nov 2018 00:56:23 +0530 Subject: [PATCH 1/2] Update src/Update/Program.cs Pass working directory as --squirrel-cwd argument to targetExe during ProcessStart --- src/Update/Program.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Update/Program.cs b/src/Update/Program.cs index 320e0cc94..339485f70 100644 --- a/src/Update/Program.cs +++ b/src/Update/Program.cs @@ -549,8 +549,9 @@ public void ProcessStart(string exeName, string arguments, bool shouldWait) if (shouldWait) waitForParentToExit(); try { - this.Log().Info("About to launch: '{0}': {1}", targetExe.FullName, arguments ?? ""); - Process.Start(new ProcessStartInfo(targetExe.FullName, arguments ?? "") { WorkingDirectory = Path.GetDirectoryName(targetExe.FullName) }); + arguments = string.IsNullOrEmpty(arguments) ? $"--squirrel-cwd=\"{Environment.CurrentDirectory}\"" : $"{arguments} --squirrel-cwd=\"{Environment.CurrentDirectory}\""; + this.Log().Info("About to launch: '{0}': {1}", targetExe.FullName, arguments); + Process.Start(new ProcessStartInfo(targetExe.FullName, arguments) { WorkingDirectory = Path.GetDirectoryName(targetExe.FullName) }); } catch (Exception ex) { this.Log().ErrorException("Failed to start process", ex); } From f9525a4235145ab39f0cf28773d95425b4fc3445 Mon Sep 17 00:00:00 2001 From: Karthikeyan Vedi Date: Tue, 6 Nov 2018 03:33:09 +0530 Subject: [PATCH 2/2] Pass working directory as an argument Pass working directory as --squirrel-cwd argument to targetExe during ProcessStart --- src/StubExecutable/StubExecutable.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/StubExecutable/StubExecutable.cpp b/src/StubExecutable/StubExecutable.cpp index a723a9b5c..1d26fbd99 100644 --- a/src/StubExecutable/StubExecutable.cpp +++ b/src/StubExecutable/StubExecutable.cpp @@ -103,8 +103,13 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, si.dwFlags = STARTF_USESHOWWINDOW; si.wShowWindow = nCmdShow; + TCHAR cwd[MAX_PATH]; + GetCurrentDirectory(MAX_PATH, cwd); + std::wstring cmdLine(L"\""); cmdLine += fullPath; + cmdLine += L"\" --squirrel-cwd=\""; + cmdLine += cwd; cmdLine += L"\" "; cmdLine += lpCmdLine;