Browse Source

updater: Fix portable OBS not being relaunched correctly

(cherry picked from commit 143877c8ffc69090ea8a32ddae05389c97bb626c)
derrod 2 years ago
parent
commit
a166ca6b4f
1 changed files with 8 additions and 3 deletions
  1. 8 3
      UI/win-update/updater/updater.cpp

+ 8 - 3
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;