Skip to content

Instantly share code, notes, and snippets.

@Azure-Agst
Created January 28, 2022 04:44
Show Gist options
  • Save Azure-Agst/e93c3e55a5c6b2f42d0b5f7fb6301701 to your computer and use it in GitHub Desktop.
Save Azure-Agst/e93c3e55a5c6b2f42d0b5f7fb6301701 to your computer and use it in GitHub Desktop.
Botched Switch Update Recovery Seript
@echo off
:: Check for all tools
set tools=hactool.exe bincmp.exe BCPKG2-1-Normal-Main.bin prod.keys
for %%f in (%tools%) do (
if NOT EXIST %%f (
echo ERROR: '%%f' is not in this directory!
goto END
)
)
:: Check for XCI
if "%~x1" neq ".xci" (
echo ERROR: Please run me with your XCI as an argument!
goto END
)
:: Extract XCI's update contents
hactool.exe -t xci --disablekeywarns --updatedir=update %1
:: Iterate thru them, and if they have relevant content, extract.
:: Reminder: 010000000000081b == BootImagePackageExFat
:: https://switchbrew.org/wiki/Title_list
for %%f in (update/*.*) do (
hactool -i -k prod.keys --disablekeywarns update/%%f | findstr 010000000000081b>NUL
if NOT ERRORLEVEL 1 (
hactool -k prod.keys --disablekeywarns --romfsdir=out update/%%f
)
)
:: Make a backup of the old BCPKG2-1-Normal-Main.bin dump
:: If a backup exists, restore from it
if EXIST BCPKG2-1-Normal-Main.bin.bak (
echo Restoring from backup...
del /f BCPKG2-1-Normal-Main.bin
copy BCPKG2-1-Normal-Main.bin.bak BCPKG2-1-Normal-Main.bin
) else (
echo Making backup...
copy BCPKG2-1-Normal-Main.bin BCPKG2-1-Normal-Main.bin.bak
)
:: Edit package2 and copy in ExFat driver
bincmp out/nx/package2 -writeto BCPKG2-1-Normal-Main.bin -offs2=16384
:END
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment