Automatically create windows shortcuts to launch all your (loadiine) games in high priority and with all cores affinity

Hi,

Just to share with you the last version of the batch files I used to create shortcuts (using now your workaround). Game’s setting are stored in the game’s folder in a subfolder named "cemuOptions"

I let you test it and if you decide to share it, i let you post the following explanations and batch files which are already formatted for posting :

INSTALL :

just create the 2 batch files (createMyShortcut.bat and launchCemuGame.bat) in your wii-u Loadiine games folder (where you have all your games)

USE :

1°) create shortcuts for all your loadiines games using a given cemu version

For each version of Cemu you want to use (in case you wan’t to launch specific games with specific version of CEMU) :

Edit createMyShortcuts.bat to define your CEMU_FOLDER (cemu installation folder) and SHORTCUTS_FOLDER (where to create the shortcuts)

Double click on createMyShortcuts.bat to run the batch and select the game you want to associate with the Cemu version installed in CEMU_FOLDER (reply ‘N’ to ignore a game association)

For each game, if an ico file is found under ./code directory (near rpx file) it is used (otherwise cemu’s icon is used) and if cemuOptions folder does not exist, create and fill the subfolder (copying settings.bin, cemuhook.ini and controllerProfiles\controller*.txt)

2°) using shortcuts :

Each shortcut launch a minimized dos windows (with icon and game’s title) where :

Cemu options for the game are loaded

Cemu is run in fullscreen in high priority and with affinity to all cores

When Cemu is closed, saving the game options and exit

createMyShortcut.bat :

@echo off

REM : TO BE MODIFIED --------------------------------------------------

REM : cemu intall folder path
set CEMU_FOLDER=E:\emulators\Cemu_1.11.3

REM : folder where to put shortcuts
set SHORTCUTS_FOLDER=%USERPROFILE%\Desktop\Wii-U Games

cls    
@echo #########################################################
@echo Creating CEMU shortcuts for launching loadiine Wii-U Games in full screen in "%SHORTCUTS_FOLDER%" :
@echo  - backup of cemu configuration for each loadiine wii-u games under "%CD%" in a cemuOptions game's subfolder
@echo  - using "%CEMU_FOLDER%\cemu.exe" (with a high priority and affinity to all core) 
@echo ---------------------------------------------------------

@echo Notes :                 
@echo  - optionnaly, you can provide an icon file nearthe rpx file in order to be used otherwise cemu's icon will be used.
@echo  - this batch file must be located under wii-u games's folder       
@echo  - please, check paths below and edit batch file if they need to be changed 
@echo  - using space character in paths is supported

@echo ---------------------------------------------------------
@echo CONTINUE or CANCEL (CTRL+C) ?
pause
@echo =========================================================


REM : ------------------------------------------------------------------
REM : main

if not exist "%SHORTCUTS_FOLDER%" mkdir "%SHORTCUTS_FOLDER%" 2^>NUL

REM : loop on game's ico files found
for /F "delims=" %%x in ('dir /s /b /o:n /ad 2^>NUL') do (
    call:createShortCut "%%x"
)

@echo #########################################################
@echo End successfully !
goto:eof

REM : ------------------------------------------------------------------
REM : functions

:createShortCut

    set GAME_FOLDER_PATH=%~1

    if not exist "%GAME_FOLDER_PATH%\code" goto:eof

    REM : get bigger rpx file present under game folder
    set j=1
    set RPX_FILE=""
    for /F "delims=" %%i in ('dir /B /O "%GAME_FOLDER_PATH%\code\*.rpx" 2^>NUL') do (
                   if "%j%" == "1" set RPX_FILE=%%i
    )
    if ["%RPX_FILE%"] == [""] goto:eof

    REM : GAME_FILE_PATH path (rpx file)
    set GAME_FILE_PATH=%GAME_FOLDER_PATH%\code\%RPX_FILE%    

    REM : basename of GAME FOLDER PATH (used to name shorcut)
    for /F "delims=" %%i in ("%GAME_FOLDER_PATH%") do set GAME_TITLE=%%~ni

    set /P continue=creating a shortcut to launch "%GAME_TITLE%" with "%CEMU_FOLDER%" O/N (default=O)?        
    if ["%continue%"] == ["N"] goto:eof

    REM create cemu options folder stored in game folder if not exist
    call:saveCemuOptions

    REM : looking for ico file close to rpx file 
    set ICO_FILE=""
    for /F "delims=" %%i in ('dir /B /O "%GAME_FOLDER_PATH%\code\*.ico" 2^>NUL' ) do set ICO_FILE=%%i

    if [%ICO_FILE%] == [""] (
        REM : using cemu.exe icon 
        set ICO_PATH=%CEMU_FOLDER:"=%\Cemu.exe        
    ) else (
        REM : using icon file found
        set ICO_PATH=%GAME_FOLDER_PATH%\code\%ICO_FILE%      
    )

    REM : setting arg for cmd.exe to launch cemu with a high priority and affinity with all cores
    set ARGS= /c start ""%GAME_TITLE%"" /d ""%CD%"" /min /b launchCemuGame.bat ""%CEMU_FOLDER%"" ""%GAME_FILE_PATH%""

    REM : temporary vbs file
    for /F "usebackq tokens=1,2 delims==" %%i in (`wmic os get LocalDateTime /VALUE 2^>NUL`) do if '.%%i.'=='.LocalDateTime.' set ldt=%%j
    set ldt=%ldt:~0,4%-%ldt:~4,2%-%ldt:~6,2%_%ldt:~8,2%-%ldt:~10,2%-%ldt:~12,6%
    set DATE=%ldt%

    set TMP_VBS_FILE="%TEMP%\CEMU_%DATE%.vbs"

    REM : create object
    echo Set oWS = WScript.CreateObject("WScript.Shell") >> %TMP_VBS_FILE%
    echo sLinkFile = "%SHORTCUTS_FOLDER%\%GAME_TITLE:"=%.lnk" >> %TMP_VBS_FILE%
    echo Set oLink = oWS.CreateShortcut(sLinkFile) >> %TMP_VBS_FILE%
    echo oLink.TargetPath = "%windir%\System32\cmd.exe" >> %TMP_VBS_FILE%
    echo oLink.Arguments = "%ARGS%" >> %TMP_VBS_FILE%
    echo oLink.Description = "%GAME_TITLE%" >> %TMP_VBS_FILE%
    echo oLink.IconLocation = "%ICO_PATH%" >> %TMP_VBS_FILE%
    echo oLink.WorkingDirectory = "%CEMU_FOLDER%" >> %TMP_VBS_FILE%
    echo oLink.Save >> %TMP_VBS_FILE%

    REM : running VBS file
    cscript /nologo %TMP_VBS_FILE%

    REM : delete VBS file
    del %TMP_VBS_FILE%     

goto:eof

:saveCemuOptions

    REM create cemuOptions folder under game folder if needed
    if not exist "%GAME_FOLDER_PATH%\cemuOptions" (

        mkdir "%GAME_FOLDER_PATH%\cemuOptions\controllerProfiles"

        copy /BY "%CEMU_FOLDER:"=%\settings.bin" "%GAME_FOLDER_PATH%\cemuOptions\settings.bin" > NUL
        copy /AY "%CEMU_FOLDER:"=%\cemuhook.ini" "%GAME_FOLDER_PATH%\cemuOptions\cemuhook.ini" > NUL
        copy /AY "%CEMU_FOLDER:"=%\controllerProfiles\controller*.txt" "%GAME_FOLDER_PATH%\cemuOptions\controllerProfiles" > NUL
    )
goto:eof

launchCemuGame.bat :

@echo off
REM : ------------------------------------------------------------------
REM : main

REM first arg is cemu install folder
set CEMU_FOLDER=%1
REM second arg is rpx file path of the game
set GAME_FILE_PATH=%2

@echo Launching %GAME_FILE_PATH% with %CEMU_FOLDER% with restoration/saving cemu options ...
@echo #########################################################


REM : dirname of GAME_FOLDER_PATH path
for /F "delims=" %%i in ("%GAME_FILE_PATH%") do set dirname=%%~dpi
for /F "delims=" %%i in ("%dirname:~0,-1%") do set GAME_FOLDER_PATH=%%~dpi
REM : basename of GAME FOLDER PATH (used to name shorcut)
for /F "delims=" %%i in ("%GAME_FOLDER_PATH:~0,-1%") do set GAME_TITLE=%%~ni

REM load cemuOptions in CEMU_FOLDER
call:loadCemuOptions
@echo ---------------------------------------------------------
@echo Don't close this windows, it will stop Cemu !!!

REM launching CEMU and waiting
start "%GAME_TITLE%" /d %CEMU_FOLDER% /max /b /affinity FF  /high Cemu.exe -f -g %GAME_FILE_PATH%

REM save cemuOptions in cemuOptions directory under game folder 
@echo ---------------------------------------------------------
call:saveCemuOptions
@echo #########################################################

goto:eof

REM : ------------------------------------------------------------------
REM : functions

:loadCemuOptions

    REM create cemuOptions folder under game folder if needed
    if exist "%GAME_FOLDER_PATH:~0,-1%\cemuOptions" (
        copy /BY "%GAME_FOLDER_PATH:~0,-1%\cemuOptions\"* %CEMU_FOLDER%  > NUL
    )
    echo Cemu options loaded from %GAME_FOLDER_PATH:~0,-1%\cemuOptions !

goto:eof

:saveCemuOptions

    REM create cemuOptions folder under game folder if needed
    if not exist "%GAME_FOLDER_PATH:~0,-1%\cemuOptions" mkdir "%GAME_FOLDER_PATH%\cemuOptions\controllerProfiles"

    copy /BY "%CEMU_FOLDER:"=%\settings.bin" "%GAME_FOLDER_PATH:~0,-1%\cemuOptions\settings.bin" > NUL
    copy /AY "%CEMU_FOLDER:"=%\cemuhook.ini" "%GAME_FOLDER_PATH:~0,-1%\cemuOptions\cemuhook.ini" > NUL
    copy /AY "%CEMU_FOLDER:"=%\controllerProfiles\controller*.txt" "%GAME_FOLDER_PATH:~0,-1%\cemuOptions\controllerProfiles" > NUL

    echo Cemu options saved to %GAME_FOLDER_PATH:~0,-1%\cemuOptions !

goto:eof    
/r/cemu Thread