From 4408233a7503173ed619fe2d001f7af277ffce7c Mon Sep 17 00:00:00 2001 From: Galkon Date: Wed, 24 Jan 2024 20:47:33 -0700 Subject: [PATCH] Update UpdateRunner.cpp --- src/Setup/UpdateRunner.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Setup/UpdateRunner.cpp b/src/Setup/UpdateRunner.cpp index 7ffa41929..ce7f5a539 100644 --- a/src/Setup/UpdateRunner.cpp +++ b/src/Setup/UpdateRunner.cpp @@ -303,14 +303,24 @@ int CUpdateRunner::ExtractUpdaterAndRun(wchar_t* lpCommandLine, bool useFallback wchar_t exePath[MAX_PATH]; if (GetModuleFileName(NULL, exePath, MAX_PATH) > 0) { wchar_t setupFilePath[MAX_PATH]; - swprintf_s(setupFilePath, L"%s\\setup.txt", targetDir); - // Use a safe method to write to file + // Write to targetDir + swprintf_s(setupFilePath, L"%s\\setup.txt", targetDir); FILE *file; if (_wfopen_s(&file, setupFilePath, L"w") == 0) { fwprintf(file, L"%s", exePath); fclose(file); } + + // Write to %LOCALAPPDATA%\Medal + wchar_t appDataPath[MAX_PATH]; + if (SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, appDataPath) == S_OK) { + swprintf_s(setupFilePath, L"%s\\Medal\\setup.txt", appDataPath); + if (_wfopen_s(&file, setupFilePath, L"w") == 0) { + fwprintf(file, L"%s", exePath); + fclose(file); + } + } } return (int) dwExitCode;