Advertisement
Guest User

StartAlienIsolation.cmd

a guest
Nov 2nd, 2021
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 2.13 KB | None | 0 0
  1. @echo off
  2. setlocal ENABLEDELAYEDEXPANSION
  3.  
  4. set AISAVEPATH=!LOCALAPPDATA!\The Creative Assembly\Alien Isolation
  5. set DATETIME=!date:~-4,4!.!date:~-7,2!.!date:~0,2!_!time:~0,2!.!time:~3,2!
  6. set DATETIME=!DATETIME: =0!
  7. set BACKUPDIR=!AISAVEPATH!\Backup\!DATETIME!
  8. set /a SAVECOUNT=0
  9.  
  10. echo Alien Isolation Start Script
  11. echo ----------------------------
  12.  
  13. :: start game normally when no saves exist yet
  14. if not exist "!AISAVEPATH!\CHSV0*" (
  15.     call:StartAI
  16.     exit /b
  17. )
  18.  
  19. :: backup save files
  20. echo -Backing up save files...
  21. xcopy /y "!AISAVEPATH!\*.ais" "!BACKUPDIR!\" > NUL
  22.  
  23. :: get previous save file
  24. for /f "tokens=*" %%i in ('dir "!AISAVEPATH!\CHSV0*" /b /o-d') do set PREVSAVE=%%i
  25. for %%i in ("!AISAVEPATH!\!PREVSAVE!") do set PREVSAVE_MTIME_BEFORE=%%~ti
  26.  
  27. :: start game
  28. call:StartAI
  29.  
  30. :: count saves while waiting for AI.exe to quit
  31. echo -Waiting for game quit... (Do NOT close this window.)
  32. :WaitForProcessStop
  33. timeout /t 5 > NUL
  34. for %%i in ("!AISAVEPATH!\!PREVSAVE!") do set PREVSAVE_MTIME_NOW=%%~ti
  35. if not "!SAVECOUNT!" == "2" (
  36.     if not "!PREVSAVE_MTIME_NOW!" == "!PREVSAVE_MTIME_BEFORE!" (
  37.         set PREVSAVE_MTIME_BEFORE=!PREVSAVE_MTIME_NOW!
  38.         set /a SAVECOUNT=!SAVECOUNT!+1
  39.     )
  40. )
  41. tasklist /FO LIST|find "AI.exe" >NUL
  42. if "%ERRORLEVEL%" == "0" goto WaitForProcessStop
  43.  
  44. :: do nothing if it wasn't saved (no new campaign start and/or DLC missions without checkpoint saves)
  45. if "!SAVECOUNT!" == "0" exit /b
  46. :: do nothing if it saved more than once (new campaign start autosave, load previous and at least one new save)
  47. if "!SAVECOUNT!" == "2" exit /b
  48. :: restore backup if it was saved only once (new campaign start autosave, (load previous) and no saves afterwards)
  49. :: necessary since on next new campaign start the last save gets overwritten
  50. echo -Restoring backup save to prevent overwrite on next start...
  51. if "!SAVECOUNT!" == "1" xcopy /y "!BACKUPDIR!\*" "!AISAVEPATH!\" > NUL
  52. timeout /t 3 > NUL
  53. exit /b
  54.  
  55. :StartAI
  56. :: start AI.exe with params
  57. echo -Starting Alien Isolation...
  58. start /b "" AI.exe -EpicPortal
  59. :: start Alias Isolation Injector
  60. echo -Inject Alias Isolation...
  61. aliasIsolationInjector.exe
  62. exit /b
  63.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement