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 the full path of the installer executable through to app on first-run #1246

Open
wants to merge 1 commit 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
8 changes: 6 additions & 2 deletions src/Setup/UpdateRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,12 @@ int CUpdateRunner::ExtractUpdaterAndRun(wchar_t* lpCommandLine, bool useFallback
lpCommandLine = L"";
}

wchar_t cmd[MAX_PATH];
swprintf_s(cmd, L"\"%s\" --install . %s", updateExePath, lpCommandLine);
// append the full path of this installer executable to the next stage of the process
wchar_t setupExePath[MAX_PATH];
GetModuleFileName(NULL, setupExePath, MAX_PATH);

wchar_t cmd[MAX_PATH * 2];
swprintf_s(cmd, L"\"%s\" --install . %s --installer-path \"%s\"", updateExePath, lpCommandLine, setupExePath);

if (!CreateProcess(NULL, cmd, NULL, NULL, false, 0, NULL, targetDir, &si, &pi)) {
goto failedExtract;
Expand Down
10 changes: 10 additions & 0 deletions src/Squirrel/UpdateManager.ApplyReleases.cs
Original file line number Diff line number Diff line change
Expand Up @@ -370,10 +370,20 @@ void executeSelfUpdate(SemanticVersion currentVersion)
async Task invokePostInstall(SemanticVersion currentVersion, bool isInitialInstall, bool firstRunOnly, bool silentInstall)
{
var targetDir = getDirectoryForRelease(currentVersion);

var args = isInitialInstall ?
String.Format("--squirrel-install {0}", currentVersion) :
String.Format("--squirrel-updated {0}", currentVersion);

var incomingArgs = Environment.GetCommandLineArgs();
var pathKeyArgIndex = Array.FindIndex(incomingArgs, arg => String.Equals(arg, "--installer-path"));
if (pathKeyArgIndex != -1 && incomingArgs.Length > pathKeyArgIndex + 1)
{
var installerPath = incomingArgs[pathKeyArgIndex + 1];
args += String.Format(" --squirrel-installer-path {0}", installerPath);
}
this.Log().Info("Incoming args to UpdateManager process: {0}", String.Join(",", incomingArgs));
this.Log().Info("Running app with args: {0}", args);
var squirrelApps = SquirrelAwareExecutableDetector.GetAllSquirrelAwareApps(targetDir.FullName);

this.Log().Info("Squirrel Enabled Apps: [{0}]", String.Join(",", squirrelApps));
Expand Down