Skip to content

Instantly share code, notes, and snippets.

@ayamkv
Last active June 11, 2024 13:58
Show Gist options
  • Save ayamkv/e23ed8ea2ad408e090ee3a49c1c6fbbd to your computer and use it in GitHub Desktop.
Save ayamkv/e23ed8ea2ad408e090ee3a49c1c6fbbd to your computer and use it in GitHub Desktop.
Launch N Backup GTA 5

Launch N' Backup GTA 5 (WIP)

A .bat file that launch GTA 5 with priority set to realtime and Backup your savegame after closing GTA 5 with rclone, you can backup with whatever rclone supports, Google Drive, One Drive, Dropbox, etc. supported remotes here.

Reminder: THIS IS A WORK IN PROGRESS

this is just my side project that i made for myself, i will consider moving this gist into a repository

How to:

  1. Modify your config files in config.txt
  2. Run the .bat file
  3. Enjoy

How to make it better?

  1. Make a shortcut file for the .bat
  2. Put it wherever you want (start, taskbar, desktop, etc)
  3. Go to the shortcut properties, change the icon and name to GTA V

Credits

Have any issues ? Reply down below!

# Your full "GTA5.exe" path, without quotation marks
EXE_PATH=
# Savegame Path
# ex : G:\GAMES\@@SAVEGAME
SAVEGAME_PATH=
# Put your RCLONE remote path here
# Ex: od:savegame/gta
RCLONE_PATH=
# Cloud Storage Name
# this is used for notification, you can put whatever you want in here
CloudStorageName=
@echo off
title Launch N' Backup GTA V
setlocal enabledelayedexpansion
for /f skip^=4 %%e in ('echo;prompt $E^|cmd.exe') do set "_$E=%%~e"
powershell -window minimize -command ""
if exist config.txt (
set "CONFIG_VALID=true"
for /F "eol=# delims=" %%A IN (config.txt) DO (
SET %%A
for /F "tokens=1,2 delims==" %%B in ("%%A") DO (
if "%%C"=="" (
echo Warning: Variable %%B is not set in the config.txt file.
set "CONFIG_VALID=false"
)
)
)
) else (
echo Please open "config.txt" and set up your config first..
timeout /t 10
exit /b 1
)
if "%CONFIG_VALID%"=="true" (
echo Configuration: Valid
GOTO TASK1
) else (
echo Configuration: file is not valid.
timeout /t 10
exit /b 1
)
:TASK1
:: echo "Game Launched"
:: TASKKILL /im GTA5.exe
START "" "%EXE_PATH%"
IF ERRORLEVEL 1 (
GOTO CONTINUE
) ELSE (
timeout /t 60
wmic process where name="GTA5.exe" CALL setpriority 256
wmic process where name="PlayGTAV.exe" CALL setpriority "idle"
GOTO LOOP
)
:LOOP
tasklist | find /i "GTA5" >nul 2>&1
IF ERRORLEVEL 1 (
GOTO CONTINUE
) ELSE (
set /a WAIT_TIME=5
for /l %%i in (%WAIT_TIME%,-1,1) do (
echo GTA5 is still running
echo Waiting for %%i seconds
<nul set /p "=!_$E![2A!_$E![0K"
timeout /t 1 /nobreak >nul
)
GOTO LOOP
)
:CONTINUE
:: GTA5
echo Game CLOSED
:: rclone mount --vfs-cache-mode full od: X:
call systemTrayNotification.bat -tooltip info -time 10000 -title "Syncing (using copy) Savegame" -text "Uploading latest savegame to %CloudStorageName% abangkuh..." -icon information
powershell -window normal -command ""
echo Running RCLONE
:UPLOAD
rclone copy --metadata --progress --stats-one-line --transfers 10 -v "%SAVEGAME_PATH%" "%RCLONE_PATH%"
if %ERRORLEVEL% EQU 0 (
echo Files Uploaded
call systemTrayNotification.bat -tooltip none -time 10000 -title "Savegame uploaded" -text "Check cmd for status!" -icon shield
) else (
echo BAD
call systemTrayNotification.bat -tooltip warning -time 5000 -title "Failed to upload Savegame!" -text "Check cmd for status, %ERRORLEVEL%" -icon warning
choice /C:YN /M:"Retry? "
IF ERRORLEVEL ==1 GOTO UPLOAD
IF ERRORLEVEL ==2 GOTO TIMEOUT
GOTO TIMEOUT
)
:TIMEOUT
timeout /t 200 /nobreak
exit /b 0
@if (@X)==(@Y) @end /* JScript comment
@echo off
setlocal
del /q /f %~n0.exe >nul 2>&1
for /f "tokens=* delims=" %%v in ('dir /b /s /a:-d /o:-n "%SystemRoot%\Microsoft.NET\Framework\*jsc.exe"') do (
set "jsc=%%v"
)
if not exist "%~n0.exe" (
"%jsc%" /nologo /out:"%~n0.exe" "%~dpsfnx0"
)
if exist "%~n0.exe" (
"%~n0.exe" %*
)
endlocal & exit /b %errorlevel%
end of jscript comment*/
import System;
import System.Windows;
import System.Windows.Forms;
import System.Drawing;
import System.Drawing.SystemIcons;
var arguments:String[] = Environment.GetCommandLineArgs();
var notificationText="Warning";
var icon=System.Drawing.SystemIcons.Hand;
var tooltip=null;
//var tooltip=System.Windows.Forms.ToolTipIcon.Info;
var title="";
//var title=null;
var timeInMS:Int32=2000;
function printHelp( ) {
print( arguments[0] + " [-tooltip warning|none|warning|info] [-time milliseconds] [-title title] [-text text] [-icon question|hand|exclamation|аsterisk|application|information|shield|question|warning|windlogo]" );
}
function setTooltip(t) {
switch(t.toLowerCase()){
case "error":
tooltip=System.Windows.Forms.ToolTipIcon.Error;
break;
case "none":
tooltip=System.Windows.Forms.ToolTipIcon.None;
break;
case "warning":
tooltip=System.Windows.Forms.ToolTipIcon.Warning;
break;
case "info":
tooltip=System.Windows.Forms.ToolTipIcon.Info;
break;
default:
//tooltip=null;
print("Warning: invalid tooltip value: "+ t);
break;
}
}
function setIcon(i) {
switch(i.toLowerCase()){
//Could be Application,Asterisk,Error,Exclamation,Hand,Information,Question,Shield,Warning,WinLogo
case "hand":
icon=System.Drawing.SystemIcons.Hand;
break;
case "application":
icon=System.Drawing.SystemIcons.Application;
break;
case "аsterisk":
icon=System.Drawing.SystemIcons.Asterisk;
break;
case "error":
icon=System.Drawing.SystemIcons.Error;
break;
case "exclamation":
icon=System.Drawing.SystemIcons.Exclamation;
break;
case "hand":
icon=System.Drawing.SystemIcons.Hand;
break;
case "information":
icon=System.Drawing.SystemIcons.Information;
break;
case "question":
icon=System.Drawing.SystemIcons.Question;
break;
case "shield":
icon=System.Drawing.SystemIcons.Shield;
break;
case "warning":
icon=System.Drawing.SystemIcons.Warning;
break;
case "winlogo":
icon=System.Drawing.SystemIcons.WinLogo;
break;
default:
print("Warning: invalid icon value: "+ i);
break;
}
}
function parseArgs(){
if ( arguments.length == 1 || arguments[1].toLowerCase() == "-help" || arguments[1].toLowerCase() == "-help" ) {
printHelp();
Environment.Exit(0);
}
if (arguments.length%2 == 0) {
print("Wrong number of arguments");
Environment.Exit(1);
}
for (var i=1;i<arguments.length-1;i=i+2){
try{
//print(arguments[i] +"::::" +arguments[i+1]);
switch(arguments[i].toLowerCase()){
case '-text':
notificationText=arguments[i+1];
break;
case '-title':
title=arguments[i+1];
break;
case '-time':
timeInMS=parseInt(arguments[i+1]);
if(isNaN(timeInMS)) timeInMS=2000;
break;
case '-tooltip':
setTooltip(arguments[i+1]);
break;
case '-icon':
setIcon(arguments[i+1]);
break;
default:
Console.WriteLine("Invalid Argument "+arguments[i]);
break;
}
}catch(e){
errorChecker(e);
}
}
}
function errorChecker( e:Error ) {
print ( "Error Message: " + e.message );
print ( "Error Code: " + ( e.number & 0xFFFF ) );
print ( "Error Name: " + e.name );
Environment.Exit( 666 );
}
parseArgs();
var notification;
notification = new System.Windows.Forms.NotifyIcon();
//try {
notification.Icon = icon;
notification.BalloonTipText = notificationText;
notification.Visible = true;
//} catch (err){}
notification.BalloonTipTitle=title;
if(tooltip!==null) {
notification.BalloonTipIcon=tooltip;
}
if(tooltip!==null) {
notification.ShowBalloonTip(timeInMS,title,notificationText,tooltip);
} else {
notification.ShowBalloonTip(timeInMS);
}
var dieTime:Int32=(timeInMS+100);
System.Threading.Thread.Sleep(dieTime);
notification.Dispose();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment