@@ -18,6 +18,8 @@ public class LaunchLogic
1818 private string MonitorPath { get ; set ; }
1919 private string MonitorName { get ; set ; }
2020 private bool LauncherPathValid { get ; set ; }
21+ private bool PreLaunchPathValid { get ; set ; }
22+ private bool PostGamePathValid { get ; set ; }
2123 private bool GamePathValid { get ; set ; }
2224 private bool LauncherURIMode { get ; set ; }
2325 private bool ExitRequested { get ; set ; }
@@ -35,6 +37,8 @@ public LaunchLogic()
3537 LauncherPathValid = SettingsData . ValidatePath ( SetHnd . Paths . LauncherPath ) ;
3638 GamePathValid = SettingsData . ValidatePath ( SetHnd . Paths . GamePath ) ;
3739 LauncherURIMode = SettingsData . ValidateURI ( SetHnd . Paths . LauncherURI ) ;
40+ PreLaunchPathValid = SettingsData . ValidatePath ( SetHnd . Paths . PreLaunchExecPath ) ;
41+ PostGamePathValid = SettingsData . ValidatePath ( SetHnd . Paths . PostGameExecPath ) ;
3842 TrayUtil = new TrayIconUtil ( ) ;
3943 }
4044
@@ -47,13 +51,16 @@ public async Task ProcessLauncher()
4751 ProcessWrapper . KillProcTreeByName ( LauncherName ) ;
4852 }
4953
50- // run PreLaunchExecPath/Args before the launcher
51- PreLauncherPL = new ProcessLauncher (
52- SetHnd . Paths . PreLaunchExecPath ,
53- SetHnd . Paths . PreLaunchExecArgs ,
54- elevate : SetHnd . Options . ElevateExternals
55- ) ;
56- await PreLauncherPL . Launch ( ) ;
54+ if ( PreLaunchPathValid )
55+ {
56+ // run PreLaunchExecPath/Args before the launcher
57+ PreLauncherPL = new ProcessLauncher (
58+ SetHnd . Paths . PreLaunchExecPath ,
59+ SetHnd . Paths . PreLaunchExecArgs ,
60+ elevate : SetHnd . Options . ElevateExternals
61+ ) ;
62+ await PreLauncherPL . Launch ( ) ;
63+ }
5764
5865 if ( LauncherPathValid && ! SetHnd . Options . SkipLauncher )
5966 {
@@ -79,11 +86,13 @@ public async Task ProcessLauncher()
7986 LauncherMonitor . ProcessAcquired += OnLauncherAcquired ;
8087
8188 // wait for all running threads to exit
82- while ( ! ExitRequested ||
89+ while (
90+ PreLauncherPL != null && PreLauncherPL . ProcWrapper . IsRunning ( ) ||
8391 LauncherMonitor != null && LauncherMonitor . IsRunning ( ) ||
8492 GameMonitor != null && GameMonitor . IsRunning ( ) ||
85- PreLauncherPL != null && PreLauncherPL . ProcWrapper . IsRunning ( ) ||
86- PostGamePL != null && PostGamePL . ProcWrapper . IsRunning ( ) )
93+ PostGamePL != null && PostGamePL . ProcWrapper . IsRunning ( ) ||
94+ ! ExitRequested
95+ )
8796 await Task . Delay ( 1000 ) ;
8897 }
8998
@@ -225,14 +234,17 @@ private async void OnGameExited(object sender, ProcessEventArgs e)
225234 if ( SetHnd . Options . MinimizeLauncher && LauncherPL . ProcWrapper . IsRunning ( ) )
226235 WindowUtils . MinimizeWindow ( LauncherPL . ProcWrapper . Hwnd ) ;
227236
228- // run PostGameExecPath/Args after the game exits
229- PostGamePL = new ProcessLauncher (
230- SetHnd . Paths . PostGameExecPath ,
231- SetHnd . Paths . PostGameExecArgs ,
232- elevate : SetHnd . Options . ElevateExternals ,
233- delayTime : SetHnd . Options . PostGameWaitTime
234- ) ;
235- await PostGamePL . Launch ( ) ;
237+ if ( PostGamePathValid )
238+ {
239+ // run PostGameExecPath/Args after the game exits
240+ PostGamePL = new ProcessLauncher (
241+ SetHnd . Paths . PostGameExecPath ,
242+ SetHnd . Paths . PostGameExecArgs ,
243+ elevate : SetHnd . Options . ElevateExternals ,
244+ delayTime : SetHnd . Options . PostGameWaitTime
245+ ) ;
246+ await PostGamePL . Launch ( ) ;
247+ }
236248
237249 if ( SetHnd . Options . PostGameWaitTime > 0 )
238250 ProcessUtils . Logger ( "OSOL" , $ "Game exited, moving on to clean up after { SetHnd . Options . PostGameWaitTime } s...") ;
0 commit comments