MR Launcher

MR Launcher

OVERVIEW
Games such as Black Desert Online is launched through a game patcher. The game patcher may detect your mod file(s) and cause problem.

MR Launcher is a script that will automate the process of:
  1. Restore from original backup of game files, so you start off clean.
  2. Launch the game patcher.
  3. Detect that the game patcher is closed, then apply the mod files as the patcher opens the game.
FUNCTIONALITIES
  • Fix: Launch without mod will now check if game files were updated.
  • New menu option - Restore from backup.
  • Exiting MR Launcher will change screen to green.

  • Restores from backup, and then launches the game patcher to avoid mod files from being detected.
  • Detects that the game patcher is closed, and applies the mod files as the game patcher launches the game.
  • Detects if patcher was manually closed and that the game didn't get launched. So the mod files will not be applied.
  • Detects if patcher has updated mod related files by comparing with backup files.
  • Automatically refreshes your backup files if the patcher has new updates.
  • Detects incorrect setup or missing files.
  • Color-coded screen colors.
    + Yellow - Waiting for your input.
    + Blue - the script is doing something.
    + Red - Error. Something went wrong.
  • Menu option - open the game folder.
  • Menu option - create MR Launcher shortcut.
  • Menu option - refresh backup files.
  • Choose to start the game with or without mod.
  • Multiple mod profiles support. e.g. Select to run the game with MOD1 or MOD2
  • Dynamically lists detected profiles (subfolders).
    e.g.
    + d:\mods\ (copies from everything under "mods")
    + d:\mods\no-weapon (copies from the no-weapon folder only)
    + d:\mods\favorite (copies from the favorite folder only)
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Though theoretically this script should work with any games using a game patcher to detect file discrepancies...

THIS SCRIPT HAS ONLY BEEN TESTED WITH BLACK DESERT ONLINE

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

INSTALLATION / SETUP
  1. Copy the MR Launcher script below, and paste it to Notepad.
  2. Read the notes on the top of the script, then verify and update the USER VARIABLES right under the notes.
  3. Save the file as "MR-Launcher.cmd" - File name: "MR-Launcher.cmd", Save as type: "All Files (*.*)
  4. Right-click MR-Launcher.cmd and choose "Run as administrator".
  5. Select option "S" to create a shortcut to your desktop.
  6. Exit the script (option X).
  7. Right-click on MR-Launcher shortuct, and choose Properties.
  8. You should be on the "Shortcut" tab of the Properties window.
  9. Click on the "Advanced" button.
  10. Checkmark "Run as administrator", then click the OKs to close.
Code:
@ECHO OFF
================================================================================
REM ! IMPORTANT!
REM --------------------------------------------------------------------------------
REM ! What you need before you start using MR Launcher:
REM ! 1. You need to have the mod files.
REM ! 2. You need to have a backup of the game files that the mod will be
REM !    overwriting.
REM ! 3. Verify & update the User Variables listed below.
REM ! 4. While both the game's patcher and the game itself are closed, run
REM !    MR Launcher to start the game.
REM ================================================================================
REM ===== USER VARIABLES =====
REM The executable file that's used to patch and launch the game and its full path.
SET "GAME-PATCHER=G:\Program Files (x86)\Black Desert Online\Black Desert Online Launcher.exe"
REM The actual game executable file and its full path.
SET "GAME-EXE=G:\Program Files (x86)\Black Desert Online\bin64\BlackDesert64.exe"
REM Folder path to where the mod files should be overwriting to.
SET "PATCH-TO=G:\Program Files (x86)\Black Desert Online\Paz"
REM Folder path to the mod files.
SET "MR-ModProfiles=%cd%\MR-ModProfiles"
REM Folder path to where the backup files are.
SET "MR-BACKUP=%cd%\MR-Backup"

REM ===== APPLICATION VARIABLES =====
for %%i in ("%GAME-EXE%") do SET "GAME-EXE-PATH=%%~dpi"
for %%i in ("%GAME-EXE%") do SET "GAME-EXE-FILE=%%~nxi"
for %%i in ("%GAME-PATCHER%") do SET "GAME-PATCHER-PATH=%%~dpi"
for %%i in ("%GAME-PATCHER%") do SET "GAME-PATCHER-FILE=%%~nxi"

REM ===== End of variables list.

:BOF
REM ===========================================================
REM ===== BEGIN MAIN PROGRAM ==================================
REM ===========================================================
COLOR 17
CLS
ECHO ===============================================================================
ECHO =                            MOD REPLACER LAUNCHER                            =
ECHO =                                    v1.1                                     =
ECHO ===============================================================================
ECHO:

:MAIN-MENU
CALL :Menu-Options SELECTION ModProfile %1
SET "voidDefault=1"
IF DEFINED ModProfile (GOTO APPLY-PROFILE)
IF "%SELECTION%"=="0" GOTO GAMELAUNCHER-PRE
IF "%SELECTION%"=="X" COLOR 2F & GOTO END
IF "%SELECTION%"=="Z" GOTO GAMEFOLDER
IF "%SELECTION%"=="B" GOTO RefreshBackup-Pre
IF "%SELECTION%"=="R" GOTO RestoreFromBackup-Pre
IF "%SELECTION%"=="S" GOTO ADDSHORTCUT

:APPLY-PROFILE
COLOR 17
IF NOT DEFINED ModProfile (GOTO BOF)
FOR %%i IN (%ModProfile%) DO (SET ModProfileName=%%~ni)
GOTO GAMELAUNCHER-PRE

:RestoreFromBackup-Pre
COLOR CF
ECHO:
ECHO ---WARNING---
ECHO This operation will overwrite files in your game folder using the files from
ECHO your backup folder:
ECHO %MR-Backup%
ECHO:
CHOICE /M "Continue to restore from backup?"
    IF ERRORLEVEL 2 CLS & GOTO END-RestoreFromBackup-Pre
    IF ERRORLEVEL 1 CALL :RestoreFromBackup
    ECHO:
    PAUSE
    :END-RestoreFromBackup-Pre
    CLS
    GOTO BOF

:RefreshBackup-Pre
COLOR CF
ECHO:
ECHO ---WARNING---
ECHO This operation will take the files from your game folder and overwrite the
ECHO backup files in your backup folder:
ECHO %MR-Backup%
ECHO:
ECHO Please make sure the current files in your game folder are un-modded original
ECHO files before you proceed.
ECHO:
CHOICE /M "Continue to refresh backup files?"
    IF ERRORLEVEL 2 CLS & GOTO END-RefreshBackup-Pre
    IF ERRORLEVEL 1 CALL :RefreshBackup
    ECHO:
    PAUSE
    :END-RefreshBackup-Pre
    CLS
    GOTO BOF

:GAMELAUNCHER-PRE
COLOR 17
REM Checks if game is already running.
CALL :VerifyGameRunning VerifyGameRunning
IF "%VerifyGameRunning%"=="1" GOTO Error-PatcherRunning
IF "%VerifyGameRunning%"=="2" GOTO Error-GameRunning
REM Restore from backup file.
CALL :RestoreFromBackup
REM Run the game patcher
ECHO:
ECHO Opening game patcher...
ECHO:
IF NOT EXIST "%GAME-PATCHER%" (SET "Error-Message=Missing game patcher (%GAME-PATCHER%)." & GOTO Error-Common)

:GAMELAUNCHER
    COLOR 17
 
    ECHO ===== Press PLAY on game patcher to proceed... =====
    ECHO:
    REM Launch patcher and wait for it to close.
    "%GAME-PATCHER%"
 
    REM Check backup files against game files to see if files were updated.
    for /f "delims=" %%F in (
      'ECHO "."^&forfiles /s /p "%MR-Backup%" /m * /c "cmd /C if @isdir==TRUE ECHO @relpath"'
    ) DO >nul 2>nul dir /a-d "%MR-Backup%\%%~F\*" && (fc /B /LB1 "%MR-Backup%\%%~F\*" "%Patch-To%\%%~F\*">NUL || GOTO Error-GameUpdated)
 
    REM Read option to run game with or without mod.
    IF DEFINED ModProfile (GOTO GAMELAUNCHER-MOD) ELSE (GOTO GAMELAUNCHER-BASE)
 
    :GAMELAUNCHER-MOD
    REM Check if patcher was manually closed by seeing if game is launched.
    CALL :VerifyGameRunning VerifyGameRunning
    IF NOT "%VerifyGameRunning%"=="2" (SET "Error-Message=%GAME-EXE-FILE% was not detected." & GOTO Error-Common)
 
    ECHO:
    ECHO Applying mod files from profile %ModProfileName%...
    ECHO:
    XCOPY /E /I /Y "%ModProfile%" "%PATCH-TO%"
    IF ERRORLEVEL 0 GOTO MOD-APPLIED
    SET "Error-Message=Error copying mod file(s)." & GOTO Error-Common
    :MOD-APPLIED
    ECHO:
    COLOR 2F
    ECHO Mod file(s) applied.
    ECHO:
    GOTO END

    :GAMELAUNCHER-BASE
    ECHO:
    COLOR 2F
    ECHO No updates detected against files from backup.
    ECHO:
    GOTO END

REM ===== END OF MAIN PROGRAM =================================
REM ===========================================================

REM ===========================================================
REM ===== SUBROUTINES =========================================
REM ===========================================================
:Menu-Options returnVar defaultOption
REM ===== Begin routine =====
    SETLOCAL EnableDelayedExpansion
    COLOR E0
    >nul 2>nul dir /a-d /s "%MR-ModProfiles%\*" && (CD /D "%MR-ModProfiles%") || (SET "Error-Message=No mod files were found in %MR-ModProfiles%." & GOTO Error-Common)
    for %%* in (.) do SET "MR-ModProfiles-Dir=%%~n*"
    :nextFolder
       SET i=1
       SET folder[1]=%cd%
       REM === MENU OPTIONS ===
       ECHO MOD PROFILES:
       ECHO     (You can open the folder by enter the profile number and a + sign.)
       ECHO:
       ECHO     [0] Launch game without applying mods.
       ECHO     [1] Launch with \%MR-ModProfiles-Dir%
       FOR /D %%d in (*) DO (
          >nul 2>nul dir /a-d /s "%%d" && (SET /A i+=1) && (SET folder[!i!]=%%d) && (ECHO     [!i!] Launch with \%MR-ModProfiles-Dir%\%%d)
       )
       ECHO:
       ECHO MORE OPTIONS:
       ECHO:
       ECHO     [S] Add MR Launcher shortcut to desktop.
       ECHO     [B] Refresh backup files.
       ECHO     [R] Restore from backup.
       ECHO     [Z] Open game folder.
       ECHO     [X] Exit MR Launcher.
       :getOption
       SET "option=0+"
       SET openFolder=1
       ECHO:
       IF NOT DEFINED voidDefault (
           IF NOT [%3]==[] (
              SET "option=%~3"
              ECHO Default selection: %3
              TIMEOUT 1 >nul
              GOTO processOption
           )
       )
       SET /P "option=Enter selection: "
       :processOption
       IF "%option:~-1%" equ "+" (
          SET option=%option:~0,-1%
       ) ELSE (
          SET openFolder=
       )
       FOR %%u IN (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) DO SET "option=!option:%%u=%%u!"
       FOR %%s IN (0 S B R Z X) DO (IF "%option%"=="%%s" GOTO returnOption)
       IF %option% GTR %i% GOTO returnOption
    IF defined openFolder (
       %SystemRoot%\explorer.exe "!folder[%option%]!"
       EXIT /B
    )
    :setModProfile
    CD !folder[%option%]!
    SET "%~1=%option%"
    ENDLOCAL & SET "%~2=%cd%"
    EXIT /B
    :returnOption
    SET "%~2="
    ENDLOCAL & SET "%~1=%option%"
    EXIT /B
REM ===== End of routine =====

:RestoreFromBackup
REM ===== Begin routine =====
setlocal
REM First checks if game is already running.
CALL :VerifyGameRunning VerifyGameRunning
IF "%VerifyGameRunning%"=="1" GOTO Error-PatcherRunning
IF "%VerifyGameRunning%"=="2" GOTO Error-GameRunning

REM Restore files if backup files exists.
>nul 2>nul dir /a-d /s "%MR-BACKUP%\*" || (SET "Error-Message=No backup files were found in %MR-BACKUP%" & GOTO Error-Common)
IF NOT EXIST "%PATCH-TO%" (SET "Error-Message=Invalid PATCH-TO folder. Cannot find %PATCH-TO%" & GOTO Error-Common)
ECHO:
ECHO Backup of original files found.
ECHO Restoring from backup...
ECHO:
COPY "%MR-BACKUP%" "%PATCH-TO%"
ECHO:
endlocal
EXIT /B
REM ===== End of routine =====

:VerifyGameRunning returnVar
REM Verify if game is already running.
REM ===== Begin routine =====
setlocal
SET "VerifyResult=0"
FOR /F "DELIMS=," %%i IN ('tasklist /NH /FO:CSV /FI "imagename eq %GAME-PATCHER-FILE%"') do (SET ImageName=%%~i)
IF "%ImageName%"=="%GAME-PATCHER-FILE%" SET "VerifyResult=1"
FOR /F "DELIMS=," %%i IN ('tasklist /NH /FO:CSV /FI "imagename eq %GAME-EXE-FILE%"') do (SET ImageName=%%~i)
IF "%ImageName%"=="%GAME-EXE-FILE%" SET "VerifyResult=2"
endlocal & SET "%~1=%VerifyResult%"
EXIT /B
REM ===== End of routine =====

:VerifyUpdate returnVar
REM Compare backup files against game files.
REM Not working.  won't return %1 value.
REM ===== Begin routine =====
    setlocal
    SET "VerifyResult=0"
    for /f "delims=" %%F in (
      'ECHO "."^&forfiles /s /p "%MR-Backup%" /m * /c "cmd /C if @isdir==TRUE ECHO @relpath"'
    ) DO >nul 2>nul dir /a-d "%MR-Backup%\%%~F\*" && (fc /B /LB1 "%MR-Backup%\%%~F\*" "%Patch-To%\%%~F\*">NUL || SET "VerifyResult=1" & GOTO different)
    :same
    endlocal & SET "%~1=%VerifyResult%"
    EXIT /B
 
    :different
    endlocal & SET "%~1=%VerifyResult%"
    EXIT /B
REM ===== End of routine =====

:RefreshBackup
REM Overwrites the backup files with current game files.
REM ===== Begin routine =====
    setlocal EnableDelayedExpansion
    for /f "delims=" %%F in (
      'forfiles /s /p "%MR-Backup%" /c "cmd /C if @isdir==FALSE ECHO @relpath "'
    ) DO (SET "BackupFile=%%~F")&(SET "BackupFile=!BackupFile:~2!")&(COPY "%PATCH-TO%\!BackupFile!" "%MR-BACKUP%\!BackupFile!")
    CALL :VerifyUpdate VerifyUpdate
    IF "%VerifyUpdate%"=="1" (GOTO Error-Restore) ELSE (GOTO End-Restore)
    :Error-Restore
    ECHO:
    ECHO !!! Error restoring files.  Please manually refresh your backup files. !!!
    ECHO:
    :End-Restore
    endlocal
    EXIT /B
REM ===== End of routine =====

:ADDSHORTCUT
REM ===== Begin routine =====
    COLOR E0
    SET /P "sParam=Set default selection (optional): "
    COLOR 17
    IF [%sParam%]==[0] (SET "s-icon=281") ELSE (SET "s-icon=250")
    IF [%sParam%]==[] (SET "s-icon=248") ELSE (SET "s-Param=-%sParam%")
    FOR %%p IN (s S b B r R z Z x X) DO (IF "%sParam%"=="%%p" SET "s-icon=288")
    set batchName=%~f0
    for %%i in ("%batchName%") do SET "batchPath=%%~dpi"
    set SCRIPT="%TEMP%\%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%.vbs"
    echo Set oWS = WScript.CreateObject("WScript.Shell") >> %SCRIPT%
    echo strDesktop = oWS.SpecialFolders("Desktop") >> %SCRIPT%
    echo Set oLink = oWS.CreateShortcut(strDesktop ^& "\MR-Launcher%s-Param%.lnk") >> %SCRIPT%
    echo oLink.WorkingDirectory = "%batchPath%" >> %SCRIPT%
    echo oLink.TargetPath = "%batchName%" >> %SCRIPT%
    echo oLink.Arguments = "%sParam%" >> %SCRIPT%
    REM echo oLink.IconLocation = "%GAME-EXE-PATH%\BlackDesert.ico" >> %SCRIPT%
    echo oLink.IconLocation = "%windir%\System32\imageres.dll,%s-icon%" >> %SCRIPT%
    echo oLink.Description = "Mod Replacer Launcher" >> %SCRIPT%
    echo oLink.Save >> %SCRIPT%
    cscript /nologo %SCRIPT%
    del %SCRIPT%
    ECHO:
    COLOR 2F
    ECHO Shortcut has been added to the desktop.
    ECHO:
    PAUSE
    CLS
    GOTO BOF
    REM %UserProfile%\Desktop\
REM ===== End of routine =====

:GAMEFOLDER
REM ===== Begin routine =====
    %SystemRoot%\explorer.exe %GAME-EXE-PATH%
    CLS
    GOTO BOF
REM ===== End of routine =====


REM ===========================================================
REM ===== Error Handling ======================================
REM ===========================================================
:Error-GameUpdated
COLOR CF
ECHO:
ECHO =====================================================================
ECHO =                              WARNING                              =
ECHO = Game file(s) was changed by the game patcher. Please reapply mod. =
ECHO =====================================================================
ECHO:
ECHO Replacing the backup of orginal files with the new version...
CALL :RefreshBackup
ECHO:
ECHO Game is launched without applying the mod. Exit the game, then
ECHO reapply the mod and try again.
ECHO:
ECHO The script will now exit.
PAUSE
EXIT

:Error-PatcherRunning
:Error-GameRunning
COLOR CF
ECHO:
ECHO ERROR: Game was already running.
ECHO:
ECHO Please only run MR Launcher when the game is closed.
ECHO:
GOTO END

:Error-Common
COLOR CF
ECHO:
ECHO ERROR: %Error-Message%
ECHO:
ECHO Mod was NOT applied!
ECHO:
GOTO END

:END
ECHO:
ECHO Exiting script.
TIMEOUT 10
EXIT

HOW TO USE
While both the game and the game patch are closed, double click the MR-Launcher shortcut and follow on-screen instructions.

NOTE TO MODDERS & DEVELOPERS
Feel free to use this script in parts or as a whole in your mods or tools.
Author
YoungKai
Views
94
First release
Last update
Rating
0.00 star(s) 0 ratings

More resources from YoungKai

Latest updates

  1. MR Launcher v1.1

    Fix: Launch without mod will now check if game files were updated. New menu option - Restore...
Top Bottom