From 0be8188bbab5d574a0e817f5febf43774b8ce4d7 Mon Sep 17 00:00:00 2001 From: Pete Miller Date: Tue, 30 Jan 2018 10:34:50 +1300 Subject: [PATCH] Pass the full path of the installer executable through to app on first-run --- src/Setup/UpdateRunner.cpp | 8 ++++++-- src/Squirrel/UpdateManager.ApplyReleases.cs | 10 ++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Setup/UpdateRunner.cpp b/src/Setup/UpdateRunner.cpp index 50d3441a2..deb44ca43 100644 --- a/src/Setup/UpdateRunner.cpp +++ b/src/Setup/UpdateRunner.cpp @@ -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; diff --git a/src/Squirrel/UpdateManager.ApplyReleases.cs b/src/Squirrel/UpdateManager.ApplyReleases.cs index 1dbd7c5f4..54ab01117 100644 --- a/src/Squirrel/UpdateManager.ApplyReleases.cs +++ b/src/Squirrel/UpdateManager.ApplyReleases.cs @@ -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));