@@ -386,6 +386,7 @@ private static void ProcessLauncher(Settings setHnd)
386386
387387 launcherProc . StartInfo . UseShellExecute = true ;
388388 launcherProc . StartInfo . FileName = setHnd . LauncherPath ;
389+ launcherProc . StartInfo . WorkingDirectory = Directory . GetParent ( setHnd . LauncherPath ) . ToString ( ) ;
389390 launcherProc . StartInfo . Arguments = setHnd . LauncherArgs ;
390391 Logger ( "OSOL" , "Attempting to start the launcher, cmd: " + setHnd . LauncherPath ) ;
391392 launcherProc . Start ( ) ;
@@ -423,11 +424,11 @@ private static void ProcessLauncher(Settings setHnd)
423424 Logger ( "FATAL" , "Cannot find main window handle of launcher process at PID [" + launcherProc . Id + "], perhaps the wrong launcher exe?" ) ;
424425 return ;
425426 }
426- } // skip over the launcher if we're only launching a game path
427427
428- // force the launcher window to activate before the game to avoid BPM hooking issues
429- Thread . Sleep ( setHnd . PreGameOverlayWaitTime * 1000 ) ; // wait for the BPM overlay notification
430- BringToFront ( launcherProc . MainWindowHandle ) ;
428+ // force the launcher window to activate before the game to avoid BPM hooking issues
429+ Thread . Sleep ( setHnd . PreGameOverlayWaitTime * 1000 ) ; // wait for the BPM overlay notification
430+ BringToFront ( launcherProc . MainWindowHandle ) ;
431+ } // skip over the launcher if we're only launching a game path
431432
432433 /*
433434 * Game Post-Proxy Detection
@@ -437,6 +438,7 @@ private static void ProcessLauncher(Settings setHnd)
437438 { // only run game ourselves if the user asks
438439 gameProc . StartInfo . UseShellExecute = true ;
439440 gameProc . StartInfo . FileName = setHnd . GamePath ;
441+ gameProc . StartInfo . WorkingDirectory = Directory . GetParent ( setHnd . GamePath ) . ToString ( ) ;
440442 gameProc . StartInfo . Arguments = setHnd . GameArgs ;
441443 Logger ( "OSOL" , "Launching game, cmd: " + setHnd . GamePath + " " + setHnd . GameArgs ) ;
442444 gameProc . Start ( ) ;
@@ -467,7 +469,7 @@ private static void ProcessLauncher(Settings setHnd)
467469
468470 int g_sanity_counter = 0 ;
469471 int gamePID = 0 ;
470- while ( g_sanity_counter <= 300 )
472+ while ( g_sanity_counter <= 300 && setHnd . LauncherPath != String . Empty )
471473 { // actively attempt to reacquire process, wait up to 5 mins
472474 if ( g_sanity_counter == 300 )
473475 {
@@ -504,15 +506,17 @@ private static void ProcessLauncher(Settings setHnd)
504506 /*
505507 * Post-Game Cleanup
506508 */
507- if ( IsRunningPID ( launcherProc . Id ) )
509+ if ( setHnd . LauncherPath != String . Empty && IsRunningPID ( launcherProc . Id ) )
508510 { // found the launcher left after the game exited
509511 Thread . Sleep ( setHnd . PostGameWaitTime * 1000 ) ; // let Origin sync with the cloud
510512 Logger ( "OSOL" , "Game exited, killing launcher instance and cleaning up..." ) ;
511513 KillProcTreeByName ( launcherName ) ;
512-
513- // ask a non-async delegate to run a process after the game and launcher exit
514- ExecuteExternalElevated ( setHnd . PostGameExec , setHnd . PostGameExecArgs ) ;
515514 }
515+ else
516+ Logger ( "OSOL" , "Game exited, cleaning up..." ) ;
517+
518+ // ask a non-async delegate to run a process after the game and launcher exit
519+ ExecuteExternalElevated ( setHnd . PostGameExec , setHnd . PostGameExecArgs ) ;
516520 }
517521 }
518522}
0 commit comments