Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass working directory as an argument during Process Start #1408

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/StubExecutable/StubExecutable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
5 changes: 3 additions & 2 deletions src/Update/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -497,8 +497,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);
}
Expand Down