SHARE
TWEET

GTAV_downgrade

Urik_Kane Sep 20th, 2019 (edited) 115 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @echo off
  2. setLocal EnableDelayedExpansion
  3.  
  4. :: ------------------------ SET VARIABLES (don't touch) ----------------------------
  5. set LauncherFolder="%userprofile%\Documents\Rockstar Games\Launcher"
  6.  
  7. :: ------------------------ USER OPTIONS ----------------------------------------------
  8. :: gamefolder will be replaced by actual game folder. BUT, you can put a completely custom path here, like "F:\my backups\gta_backup" , BUT please use " marks if your path has spaces!
  9. set backupfolder=gamefolder\_backup
  10. :: ----------------------------------------------------------------------------------------
  11.  
  12. :Start
  13. :GetGameFolder
  14. if exist %LauncherFolder% (
  15. cd /d %LauncherFolder%
  16. for /f tokens^=2^ delims^=^" %%i in ('type launcher.log ^|find "GTA5.exe"') do set "exepath=%%i"
  17. if "!exepath!"=="" ( echo ERROR: COULD NOT DETECT GAMEFOLDER & pause & goto :eof )
  18. set gamepath="!exepath:\GTA5.exe=!"
  19. if exist !gamepath! ( set "gamefolder=!gamepath!" ) else ( echo ERROR: COULD NOT DETECT GAMEFOLDER & pause & goto :eof )
  20. echo Detected Game Folder !gamepath! & echo.
  21. ) else ( echo Warning: CAN'T FIND LAUNCHER FOLDER %LauncherFolder% & pause & goto :eof )
  22.  
  23. :GetVersion
  24. set exepath2=!exepath:\=\\!
  25. for /f "tokens=*" %%V in ( ' wmic datafile where "name='!exepath2!'" get version ' ) do (
  26.     for /F "delims=" %%A IN ("%%V") do (
  27.         if not "%%V"=="" (
  28.             if not "%%V"=="Version" set "version=%%V"  
  29.         )
  30.     )
  31. )
  32. set "version=%version: =%"
  33. if '!version!'=='' ( echo ERROR: COULD NOT DETECT VERSION & pause & goto :eof ) else ( echo Game Version: %version% )
  34.  
  35. :GetPlatform
  36. cd /d %LauncherFolder%
  37.     if exist launcher.log (
  38.     for /f "tokens=*" %%i in ('type launcher.log ^|find "Running in Steam mode"') do set "Is_Steam=true"
  39.     ) else (
  40.     echo ERROR: CAN'T FIND %cd%\launcher.log
  41. )
  42.  
  43. :SetFileList
  44. if defined is_steam ( set files_tocopy=GTA5.exe,GTAVLauncher.exe,steam_api64.dll,update\update.rpf ) else ( set files_tocopy=GTA5.exe,GTAVLauncher.exe,update\update.rpf )
  45.  
  46. :CheckBackupFolder
  47. set backupfolder=%backupfolder:gamefolder=!gamefolder!%
  48. set backupfolder=%backupfolder:"=%
  49. set backupfolder="%backupfolder%"
  50. if exist %backupfolder% (
  51.     echo. & echo Backup Folder %backupfolder% & echo.
  52.     set bkup_count=0
  53.     set lastbkup_counter=0
  54.     cd /d %backupfolder%
  55.     for /f "tokens=* delims= " %%A in ( ' dir /b /-p /o:-n /t:w *.* ' ) do (
  56.         set "var=" & for /f "delims=.0123456789" %%i in ('echo %%A') do set var=%%i
  57.         if "!var!"=="" (
  58.             set "var="
  59.             set /a bkup_count=!bkup_count!+1
  60.             if !bkup_count!==1 set "last_backup=%%A"
  61.             if !bkup_count!==2 set "prev_backup=%%A"
  62.             if not "!backups!"=="" ( set "backups=!backups!,%%A") else ( set "backups=%%A")
  63.             echo found backup %%A
  64.         )
  65.     )
  66.     if !bkup_count!==0 echo NO BACKUPS HAVE BEEN FOUND. EXITING. & pause & goto :eof
  67.  
  68. ) else ( echo ERROR: CAN'T FIND BACKUPFOLDER & pause & goto :eof )
  69.  
  70.  
  71. :CheckEXE
  72. if %version%==%last_backup% ( set "do_downgrade=true" ) else (
  73.     if %version% GTR %last_backup% ( echo. & echo New version %version% , not yet backed up. Please backup first! & echo. & pause & goto :eof ) else (
  74.         if not exist %backupfolder%\%version% ( echo. & echo Old version %version% , no backup. Please back that up first! & echo. & pause & goto :eof)
  75.     )
  76. )
  77.  
  78. :Prompt
  79. echo.
  80. if defined do_downgrade ( set "msg=Downgrade from %version% to version %prev_backup%" ) else ( set "msg=Re-Update from %version% to version %last_backup%" )
  81. set /p "proceed=%msg% (Y/N)?"
  82. set "proceed=!proceed: =!"
  83. if /i not !proceed!==y goto :eof
  84.  
  85. :Process
  86. if defined do_downgrade ( CALL :CopyFromBackup %prev_backup%) else ( CALL :CopyFromBackup %last_backup%)
  87.  
  88. :Report
  89. if not "!copycount!"==""  (
  90. echo.
  91. echo ---------------------------------------------------------------------------------------
  92. echo  Copied !copycount! files: !copiedfiles!
  93. echo ---------------------------------------------------------------------------------------
  94. )
  95. if not "!failcount!"==""  (
  96. echo.
  97. echo ---------------------------------------------------------------------------------------
  98. echo  FAILED TO COPY !failcount! files: !failedfiles!
  99. echo ---------------------------------------------------------------------------------------
  100. )
  101. echo.
  102. pause
  103. goto :eof
  104.  
  105.  
  106. :CopyFromBackup
  107. echo.
  108. for %%F in (%files_tocopy%) do (
  109.     for /f "delims=" %%i in ('certutil -v -hashfile %gamefolder%\%%F MD5 ^| find /i /v "md5" ^| find /i /v "certutil"') do set "hash1=%%i"
  110.     for /f "delims=" %%i in ('certutil -v -hashfile %backupfolder%\%1\%%F MD5 ^| find /i /v "md5" ^| find /i /v "certutil"') do set "hash2=%%i"
  111.         if not !hash1!==!hash2! (
  112.         echo. & echo %%F
  113.         copy %backupfolder%\%1\%%F %gamefolder%\%%F
  114.         if "!errorlevel!"=="0" ( CALL :LogSuccess %%F) else ( CALL :LogFailure %%F)
  115.         )
  116. )
  117. goto :eof
  118.  
  119. :LogFailure
  120. if "!failcount!"=="" ( set "failcount=1" ) else ( set /a "failcount=!failcount!+1" )
  121. if "!failedfiles!"=="" ( set "failedfiles=%1" ) else ( set "failedfiles=!failedfiles!, %1" )
  122. goto :eof
  123.  
  124. :LogSuccess
  125. if "!copycount!"=="" ( set "copycount=1" ) else ( set /a "copycount=!copycount!+1" )
  126. if "!copiedfiles!"=="" ( set "copiedfiles=%1" ) else ( set "copiedfiles=!copiedfiles!, %1" )
  127. goto :eof
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top