modmii.github.io/Support/ExploitAppSelector.bat
2023-03-10 03:37:08 +02:00

194 lines
5.1 KiB
Batchfile

@echo off
setlocal
::chdir /d "%~dp0"
pushd "%~dp0"
cls
chcp 437>nul
set DRIVE=
::check if local
if not exist apps goto:skip
set DRIVE=%cd%
if /i "%DRIVE:~-1%" EQU "\" set DRIVE=%DRIVE:~0,-1%
dir "%DRIVE%\apps\*.dol" "%DRIVE%\apps\*.elf" /B /S>%temp%\applist.txt
if not errorlevel 1 goto:gotdrive
set DRIVE=
:skip
if not exist Support cd..
::check for modmii drive setting
if not exist Support\settings.bat goto:skip
::remove setting path's with an & symbol and force default
if exist Support\sfk.exe Support\sfk filter -spat Support\settings.bat -!"\x26" -write -yes>nul
call Support\settings.bat
if "%DRIVE%"=="" (goto:skip)
if /i "%DRIVE:~1,1%" NEQ ":" set DRIVE=%cd%\%DRIVE%
dir "%DRIVE%\apps\*.dol" "%DRIVE%\apps\*.elf" /B /S >%temp%\applist.txt
if not errorlevel 1 (move /y %temp%\applist.txt %temp%\applist.txt>nul) & (goto:gotdrive)
set DRIVE=
:skip
::check for COPY_TO_SD
if not exist COPY_TO_SD\apps goto:skip
set DRIVE=%cd%\COPY_TO_SD
dir "%DRIVE%\apps\*.dol" "%DRIVE%\apps\*.elf" /B /S>%temp%\applist.txt
if not errorlevel 1 goto:gotdrive
set DRIVE=
:skip
:noapps
echo Exploit App Selector
echo by XFlak
echo.
echo This tool will help you quickly switch the boot.dol\elf app that is saved to the root of your SD Card to be launched by Wii Exploits.
echo.
echo *If you're seeing this message something went wrong, make sure this file is saved to the root of your SD Card or COPY_TO_SD folder and that it has an apps folder with some Wii apps in it.
echo.
echo Press any key to exit . . .
pause>nul
exit
:gotdrive
cls
echo Exploit App Selector
echo by XFlak
echo.
echo This tool will help you quickly switch the boot.dol\elf app that is saved to the root of your SD Card to be launched by Wii Exploits.
echo.
echo Confirm this your SD Card or COPY_TO_SD folder: %DRIVE%
echo *If this isn't right, make sure this file is saved to the root of your SD Card or COPY_TO_SD folder and that it has an apps folder with some Wii apps in it.
echo.
echo Select the App to start when an exploit is launched on your Wii:
echo.
::Loop through the the following once for EACH line in *.txt
set /a line=0
for /F "tokens=*" %%A in (%temp%\applist.txt) do call :process %%A
goto:quickskip
:process
set file=%*
::skip any lines ending in bootmini.elf
if /i "%file:~-12%" EQU "bootmini.elf" goto:EOF
set /a line=%line%+1
echo %line% = %file%
goto:EOF
:quickskip
echo.
echo Notes: * Not all exploits support Dols; however, Elf files work with all exploits.
echo * Bannerbomb v1 and v2 will prioritize launching Dols over Elfs.
echo * If you have issues launching an app's Elf, try its Dol instead and vice versa.
echo * If the app you want to select isn't listed above, save it here and try again:
echo %DRIVE%\apps
echo.
set /p selection= Enter Selection Here:
if /i "%selection%" EQU "exit" exit
::check if numeric
SET "var="&for /f "delims=0123456789" %%i in ("%selection%") do set var=%%i
if defined var goto:badkey
if /i %selection% GTR %line% goto:badkey
::Loop through the the following once for EACH line in *.txt
set /a line=0
for /F "tokens=*" %%A in (%temp%\applist.txt) do call :process %%A
goto:quickskip
:process
set file=%*
::skip any lines ending in bootmini.elf
if /i "%file:~-12%" EQU "bootmini.elf" goto:EOF
set /a line=%line%+1
if /i "%line%" EQU "%selection%" goto:quickskip
goto:EOF
:quickskip
::make backup
if exist "%Drive%\boot.dol" goto:overwriteQ
if not exist "%Drive%\boot.elf" goto:skiprename
:overwriteQ
echo.
echo Boot.dol\elf already detected in %DRIVE%
echo Overwrite\Delete or Rename? O/R
echo.
set /p selection= Enter Selection Here:
if /i "%selection%" EQU "R" goto:skip
if /i "%selection%" NEQ "O" goto:notO
if exist "%Drive%\boot.elf" del "%Drive%\boot.elf">nul
if exist "%Drive%\boot.dol" del "%Drive%\boot.dol">nul
goto:skiprename
:notO
cls
echo You Have Entered an Incorrect Key
@ping 127.0.0.1 -n 2 -w 1000> nul
cls
goto:overwriteQ
:skip
echo.
if not exist "%Drive%\boot.dol" goto:skip
:COPY
SET /a COUNT=%COUNT%+1
if exist "%Drive%\boot%COUNT%.dol" goto:COPY
rename "%Drive%\boot.dol" "boot%COUNT%.dol"
echo Renaming "%Drive%\boot.dol" to "boot%COUNT%.dol"
:skip
if not exist "%Drive%\boot.elf" goto:skiprename
set /a COUNT=0
:COPY2
SET /a COUNT=%COUNT%+1
if exist "%Drive%\boot%COUNT%.elf" goto:COPY2
rename "%Drive%\boot.elf" "boot%COUNT%.elf"
echo Renaming "%Drive%\boot.elf" to "boot%COUNT%.elf"
:skiprename
::get app name
echo set app=%%file:%DRIVE%\apps\=%%>%temp%\app.bat
call %temp%\app.bat
echo.
echo Copying "..\%app%" to "%Drive%\boot.%file:~-3%"...
copy /y "%file%" "%Drive%\boot.%file:~-3%">nul
if errorlevel 1 goto:fail
echo.
echo FINISHED!
echo.
echo Safely remove your SD Card and insert it into your Wii. The next time you launch an exploit it will load a copy of %app%.
echo.
echo Press any key to exit . . .
pause>nul
exit
:badkey
echo You Have Entered an Incorrect Key
@ping 127.0.0.1 -n 2 -w 1000> nul
goto:gotdrive
:fail
echo.
echo *If you're seeing this message something went wrong.
echo.
echo Press any key to exit . . .
pause>nul
exit