Sharing my start up batch files....

Discussion in 'General Discussion' started by Woodee, Mar 11, 2021.

  1. Woodee

    Woodee Registered

    Joined:
    Oct 4, 2010
    Messages:
    4,004
    Likes Received:
    1,058
    I use a batch file to open rF2 in VR mode or desktop mode (without changing gfx config). It keeps my gfx settings for each mode so I can run hi-res on desktop and lower res in VR. Also the advantage is I can open all the apps I want before opening rF2 (weather, crew chief etc...). The gfx settings are global for each rf2 profile so this prevents me having to reconfigure each time.

    As you can see I have made a "_backup" folder in my rfactor 2 main directory and put my backed up config files. I opened rF2, did all my adjustments for gfx settings, then backed up "config_dx11.ini" for VR and desktop. On every run of the batch (choice 1 - 4), it copies the backup to overwrite the current then boots up rF2.

    I also have two user profiles and use the Steam command line arguments to startup in that profile. Be aware that you won't see Steam warn about this (annoying as it is!) unless the Steam app is open.

    Each section starts with a colon, :start is the menu screen of the cmd window. Each option will run quick then return to the menu (apart from 6 and 7, they will exit batch after running). I have recently added the code from @svictor (https://forum.studio-397.com/index.php?threads/new-ui-wishlist.67110/page-5#post-1062863) to set my player files to "All Tracks and cars", many thanks.

    This batch runs from the rF2 main folder.

    I take no responsibility for damage of your own files, use at your own risk. If you need parts explained.... ASK.

    Code:
    @echo off
    cls
    :start
    echo
    echo 1 Game in VR, realtime weather and live timing
    echo 2 Game in VR, realtime weather
    echo 3 Game in VR ONLY
    echo 4 Game on desktop ONLY
    echo 5 Backup VR files
    echo 6 Backup Non-VR files
    echo 7 Exit
    set /p choice=How would you like to launch the game?
    rem if not '%choice%'== set choice=%choice:~0,1%
    if '%choice%'=='' ECHO "%choice%" is not valid please try again
    if '%choice%'=='1' goto :choice1
    if '%choice%'=='2' goto :choice2
    if '%choice%'=='3' goto :choice3
    if '%choice%'=='4' goto :choice4
    if '%choice%'=='5' goto :choice5
    if '%choice%'=='6' goto :choice6
    if '%choice%'=='7' goto :choice7
    echo
    goto start
    
    :choice1
    echo setting player file to all cars and tracks
    echo
    SET playerfile=UserData\playervr\playervr.JSON
    for /f "delims=:" %%N in ('findstr /b /n /r /c:"^ *\"Game Description\":" %playerfile%') do set LineNum=%%N
    SET Replacement=    "Game Description":"All Tracks ^& Cars"^,
    
    move /y %playerfile% %playerfile%.bak
    setlocal enableDelayedExpansion
    (
       for /F "tokens=1* delims=:" %%a in ('findstr /N "^" %playerfile%.bak') do (
          set "line=%%b"
          IF %%a equ %LineNum% SET "Line=%Replacement%"
          echo(!line!
       )
    ) > %playerfile%
    endlocal
    echo starting game
    echo
    g:
    xcopy /Y "G:\Games (Steam)\steamapps\common\rFactor 2\_backup\VR\config_DX11.ini" "G:\Games (Steam)\steamapps\common\rFactor 2\userdata"
    cd\Games (Steam)\steamapps\common\rFactor 2\Bin64
    rfactor2.exe +profile="playervr"
    echo start live timing
    start /d "c:\Users\Neil Wood\Google Drive\Games\Programs\rF2 Log Analyzer" r2la_live_timing.bat
    echo start realtime weather
    start /d "c:\Users\Neil Wood\Google Drive\Games\Programs\rf2WeatherPlugin" rf2WeatherClient.exe
    echo start crew chief
    start /d "C:\Program Files (x86)\Britton IT Ltd\CrewChiefV4" CrewChiefV4.exe
    cls
    goto start
    :choice2
    echo setting player file to all cars and tracks
    echo
    SET playerfile=UserData\playervr\playervr.JSON
    for /f "delims=:" %%N in ('findstr /b /n /r /c:"^ *\"Game Description\":" %playerfile%') do set LineNum=%%N
    SET Replacement=    "Game Description":"All Tracks ^& Cars"^,
    
    move /y %playerfile% %playerfile%.bak
    setlocal enableDelayedExpansion
    (
       for /F "tokens=1* delims=:" %%a in ('findstr /N "^" %playerfile%.bak') do (
          set "line=%%b"
          IF %%a equ %LineNum% SET "Line=%Replacement%"
          echo(!line!
       )
    ) > %playerfile%
    endlocal
    echo starting game
    echo
    g:
    xcopy /Y "G:\Games (Steam)\steamapps\common\rFactor 2\_backup\VR\config_DX11.ini" "G:\Games (Steam)\steamapps\common\rFactor 2\userdata"
    cd\Games (Steam)\steamapps\common\rFactor 2\Bin64
    rfactor2.exe +profile="playervr"
    echo start realtime weather
    start /d "c:\Users\Neil Wood\Google Drive\Games\Programs\rf2WeatherPlugin" rf2WeatherClient.exe
    echo start crew chief
    start /d "C:\Program Files (x86)\Britton IT Ltd\CrewChiefV4" CrewChiefV4.exe
    cls
    goto start
    :choice3
    echo setting player file to all cars and tracks
    echo
    SET playerfile=UserData\playervr\playervr.JSON
    for /f "delims=:" %%N in ('findstr /b /n /r /c:"^ *\"Game Description\":" %playerfile%') do set LineNum=%%N
    SET Replacement=    "Game Description":"All Tracks ^& Cars"^,
    
    move /y %playerfile% %playerfile%.bak
    setlocal enableDelayedExpansion
    (
       for /F "tokens=1* delims=:" %%a in ('findstr /N "^" %playerfile%.bak') do (
          set "line=%%b"
          IF %%a equ %LineNum% SET "Line=%Replacement%"
          echo(!line!
       )
    ) > %playerfile%
    endlocal
    echo starting game
    echo
    g:
    xcopy /Y "G:\Games (Steam)\steamapps\common\rFactor 2\_backup\VR\config_DX11.ini" "G:\Games (Steam)\steamapps\common\rFactor 2\userdata"
    cd\Games (Steam)\steamapps\common\rFactor 2\Bin64
    rfactor2.exe +profile="playervr"
    cls
    goto start
    :choice4
    g:
    xcopy /Y "G:\Games (Steam)\steamapps\common\rFactor 2\_backup\non-VR\config_DX11.ini" "G:\Games (Steam)\steamapps\common\rFactor 2\userdata"
    cd\Games (Steam)\steamapps\common\rFactor 2\Bin64
    rfactor2.exe +profile="player"
    cls
    goto start
    :choice5
    g:
    xcopy /Y "G:\Games (Steam)\steamapps\common\rFactor 2\userdata\config_dx11.ini" "G:\Games (Steam)\steamapps\common\rFactor 2\_backup\VR"
    cls
    goto end
    :choice6
    g:
    xcopy /Y "G:\Games (Steam)\steamapps\common\rFactor 2\userdata\config_dx11.ini" "G:\Games (Steam)\steamapps\common\rFactor 2\_backup\non-VR"
    cls
    goto end
    :choice7
    goto end
    :end
    exit
     
    Last edited: Mar 11, 2021
    DJCruicky, atomed, lagg and 2 others like this.
  2. Seven Smiles

    Seven Smiles Registered

    Joined:
    Oct 5, 2010
    Messages:
    1,099
    Likes Received:
    1,152
    I spent a few minutes improving your batch file, the only important change is pulling out the paths to the various programs into the Edit these to suit your PC section at the beginning to make it easier for others to edit it for their use. It also runs from anywhere now, not just from the rF2 main folder. I notice that choice 4 doesn't do the All Cars and Tracks thing, I put it in but commented out.
    Edit: tweaked it a bit more, note that Crew Chief is not used in choices 3 & 4
    Code:
       
        @echo off
        cls
        setlocal
        REM Edit these to suit your PC
        set rf2dir="G:\Games (Steam)\steamapps\common\rFactor 2"
        REM config_DX11.ini files are in %rF2dir%"\_backup\VR" and %rF2dir%"\_backup\non-VR"
        set rf2WeatherPluginDir="c:\Users\Neil Wood\Google Drive\Games\Programs\rf2WeatherPlugin"
        set rf2LogAnalyzerDir="c:\Users\Neil Wood\Google Drive\Games\Programs\rF2 Log Analyzer"
        set CrewChiefDir="C:\Program Files (x86)\Britton IT Ltd\CrewChiefV4"
        REM 
    
    :start
        echo.
        echo 1 Game in VR, realtime weather and live timing
        echo 2 Game in VR, realtime weather
        echo 3 Game in VR ONLY
        echo 4 Game on desktop ONLY
        echo 5 Backup VR files
        echo 6 Backup Non-VR files
        echo 7 Exit
        set /p choice=How would you like to launch the game?
        rem if not '%choice%'== set choice=%choice:~0,1%
        if '%choice%'=='' ECHO "%choice%" is not valid please try again
        if '%choice%'=='1' goto :choice1
        if '%choice%'=='2' goto :choice2
        if '%choice%'=='3' goto :choice3
        if '%choice%'=='4' goto :choice4
        if '%choice%'=='5' goto :choice5
        if '%choice%'=='6' goto :choice6
        if '%choice%'=='7' goto :choice7
        echo.
        goto start
       
    :choice1
        call :AllCarsAndTracks playervr
        echo starting game
        echo.
        xcopy /Y %rF2dir%"\_backup\VR\config_DX11.ini" %rF2dir%"\userdata"
        pushd %rF2dir%"\Bin64
        rfactor2.exe +profile="playervr"
        call :LiveTiming
        call :RealTimeWeather
        call :CrewChief
        cls
        goto start
    :choice2
        call :AllCarsAndTracks playervr
        echo starting game
        echo.
        xcopy /Y %rF2dir%"\_backup\VR\config_DX11.ini" %rF2dir%"\userdata"
        pushd %rF2dir%"\Bin64
        rfactor2.exe +profile="playervr"
        call :RealTimeWeather
        call :CrewChief
        cls
        goto start
    :choice3
        call :AllCarsAndTracks playervr
        echo starting game
        echo.
        xcopy /Y %rF2dir%"\_backup\VR\config_DX11.ini" %rF2dir%"\userdata"
        pushd %rF2dir%"\Bin64
        rfactor2.exe +profile="playervr"
        REM not in original version????   call :CrewChief
        cls
        goto start
    :choice4
        REM not in original version????   call :AllCarsAndTracks player
        xcopy /Y %rF2dir%"\_backup\non-VR\config_DX11.ini" %rF2dir%"\userdata"
        pushd %rF2dir%"\Bin64
        rfactor2.exe +profile="player"
        REM not in original version????   call :CrewChief
        cls
        goto start
    
    :choice5
        echo on
        @echo d | xcopy /Y %rF2dir%"\userdata\config_dx11.ini" %rF2dir%"\_backup\VR"
        @echo off
        goto end
    :choice6
        echo on
        @echo d | xcopy /Y %rF2dir%"\userdata\config_dx11.ini" %rF2dir%"\_backup\non-VR"
        @echo off
        goto end
    :choice7
        goto end
    
    ::::::::::::::: Subroutines :::::::::::::::
    :AllCarsAndTracks
        echo setting player file to all cars and tracks
        echo.
        SET playerfile=UserData\%1\%1.JSON
        pushd %rF2dir%
        for /f "delims=:" %%N in ('findstr /b /n /r /c:"^ *\"Game Description\":" %playerfile%') do set LineNum=%%N
        SET Replacement=    "Game Description":"All Tracks ^& Cars"^,
       
        move /y %playerfile% %playerfile%.bak
        setlocal enableDelayedExpansion
        (
           for /F "tokens=1* delims=:" %%a in ('findstr /N "^" %playerfile%.bak') do (
              set "line=%%b"
              IF %%a equ %LineNum% SET "Line=%Replacement%"
              echo(!line!
           )
        ) > %playerfile%
        endlocal
        popd
        goto :eof
    
    :LiveTiming
        call :startApp Live Timing        %rf2LogAnalyzerDir% r2la_live_timing.bat
        goto :eof
    
    :RealTimeWeather
        call :startApp Realtime Weather   %rf2WeatherPluginDir% rf2WeatherClient.exe
        goto :eof
    
    :CrewChief
        call :startApp Crew Chief         %CrewChiefDir% CrewChiefV4.exe -game RF2
        goto :eof
    
    :startApp
        if exist %3\"%4" (
            echo start %1 %2%
            start /d %3 %4 %5 %6
        ) else (
            echo %3\"%4" not found
            pause
        )
        goto :eof
    
    :end
        rem Kill Logitech Profiler if it's running otherwise Steam tends to think rFactor is still running
        %SystemRoot%\System32\qprocess.exe LWEMon.exe >nul 2>&1
        if not errorlevel 1 taskkill /IM "LEWMon.exe" /F
        %SystemRoot%\System32\qprocess.exe CrewChiefV4.exe >nul 2>&1
        if not errorlevel 1 taskkill /IM "CrewChiefV4.exe" /F
    
        REM exit
    
    
     
    Last edited: Mar 11, 2021
    Hazi, DJCruicky, Dave^ and 1 other person like this.
  3. Seven Smiles

    Seven Smiles Registered

    Joined:
    Oct 5, 2010
    Messages:
    1,099
    Likes Received:
    1,152
    I wrote something similar but it also starts up Oculus, Steam and Discord and offers a menu of other games. I never published it as I thought it was too specific to my needs. This gives a taste of it

    Code:
    ***********
    Game Runner
    ***********
    
    Game selection
    
    1) rF2
    2) Assetto Corsa
    3) Assetto Corsa Competizione
    4) Automobilista
    5) Automobilista 2
    6) Project Cars 2
    7) RaceRoom Racing Experience
    8) F1_2015
    9) F1_2019
    D) DR2
    G) GTR2
    
    A) American Truck Simulator
    B) Euro Truck Simulator 2
    E) Elite Horizons
    F) FIFA 20
    M) MudRunner
    
    0) No game (debug)
    
    Choice? :1
    Running rF2
    1) VR offline
    2) VR online
    3) 2K monitor (offline)
    4) 2K monitor (online)
    5) 4K monitor (replay)
    D) 2K monitor (windowed for debugging)
    
    Choice? :
     
    Last edited: Mar 11, 2021
  4. Woodee

    Woodee Registered

    Joined:
    Oct 4, 2010
    Messages:
    4,004
    Likes Received:
    1,058
    Noice.
     
    Seven Smiles likes this.

Share This Page