From 143877c8ffc69090ea8a32ddae05389c97bb626c Mon Sep 17 00:00:00 2001 From: derrod Date: Thu, 12 Jan 2023 22:33:55 +0100 Subject: [PATCH] updater: Fix portable OBS not being relaunched correctly --- UI/win-update/updater/updater.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/UI/win-update/updater/updater.cpp b/UI/win-update/updater/updater.cpp index f65808fa1..0a1cd2ac4 100644 --- a/UI/win-update/updater/updater.cpp +++ b/UI/win-update/updater/updater.cpp @@ -1754,7 +1754,7 @@ static void CancelUpdate(bool quit) } } -static void LaunchOBS() +static void LaunchOBS(bool portable) { wchar_t cwd[MAX_PATH]; wchar_t newCwd[MAX_PATH]; @@ -1794,6 +1794,9 @@ static void LaunchOBS() execInfo.lpDirectory = newCwd; execInfo.nShow = SW_SHOWNORMAL; + if (portable) + execInfo.lpParameters = L"--portable"; + ShellExecuteEx(&execInfo); } @@ -1907,6 +1910,8 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR lpCmdLine, int) GetCurrentDirectoryW(_countof(cwd) - 1, cwd); is32bit = wcsstr(cwd, L"bin\\32bit") != nullptr; + bool isPortable = wcsstr(lpCmdLine, L"Portable") != nullptr || + wcsstr(lpCmdLine, L"--portable") != nullptr; if (!IsWindows10OrGreater()) { MessageBox( @@ -1942,7 +1947,7 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR lpCmdLine, int) nullptr); SetCurrentDirectory(newPath); - LaunchOBS(); + LaunchOBS(isPortable); } if (hLowMutex) { @@ -1990,7 +1995,7 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR lpCmdLine, int) WinHandle hMutex = OpenMutex( SYNCHRONIZE, false, L"OBSUpdaterRunningAsNonAdminUser"); if (msg.wParam == 1 && !hMutex) { - LaunchOBS(); + LaunchOBS(isPortable); } return (int)msg.wParam;