Skip to content

Instantly share code, notes, and snippets.

@eladkarako
Last active August 17, 2026 08:08
Show Gist options
  • Select an option

  • Save eladkarako/92ea3c8b94626e5a6737b8cb2cdc8066 to your computer and use it in GitHub Desktop.

Select an option

Save eladkarako/92ea3c8b94626e5a6737b8cb2cdc8066 to your computer and use it in GitHub Desktop.
UUP Dump rewrites..
@setlocal DisableDelayedExpansion
@echo off
:: =============================== BEGIN MAIN ===============================
:: Parse args (spaces preserved), detect architecture relaunch needs
set "_ARGS=%*"
set "_REL1="
set "_REL2="
if not defined _ARGS goto NO_PROG_ARGS
for %%A in (%_ARGS%) do (
if /i "%%A"=="-WOW" set "_REL1=1"
if /i "%%A"=="-ARM" set "_REL2=1"
)
:NO_PROG_ARGS
set "_CMD_F=%~f0"
:: Relaunch in 32/64-bit context if required
if exist "%SystemRoot%\Sysnative\cmd.exe" if not defined _REL1 (
setlocal EnableDelayedExpansion
start "%SystemRoot%\Sysnative\cmd.exe" /c """!_CMD_F!" -WOW "
exit /b
)
if exist "%SystemRoot%\SysArm32\cmd.exe" if /i "%PROCESSOR_ARCHITECTURE%"=="AMD64" if not defined _REL2 (
setlocal EnableDelayedExpansion
start "%SystemRoot%\SysArm32\cmd.exe" /c """!_CMD_F!" -ARM "
exit /b
)
:: Null redirection target
set "_NULL=1>nul 2>nul"
:: Base paths
set "SYS_PATH=%SystemRoot%\System32"
if exist "%SystemRoot%\Sysnative\reg.exe" set "SYS_PATH=%SystemRoot%\Sysnative"
set "PATH=%SYS_PATH%;%SystemRoot%;%SYS_PATH%\Wbem;%SYS_PATH%\WindowsPowerShell\v1.0\"
:: Admin check
whoami /groups | findstr /i /c:"S-1-16-16384" /c:"S-1-16-12288" %_NULL% || (
echo.
echo This script require administrator privileges.
goto THE_END
)
:: Drive + OS arch
set "_DRV=%~d0"
set "X_OS=%PROCESSOR_ARCHITECTURE%"
if /i "%PROCESSOR_ARCHITECTURE%"=="x86" (
if defined PROCESSOR_ARCHITEW6432 set "X_OS=%PROCESSOR_ARCHITEW6432%"
)
:: DISM WIM key base
set "_KEY=HKLM\SOFTWARE\Microsoft\WIMMount\Mounted Images"
:: Flags (cleanup mounted images / temp directories)
set "_MOUNTED=0"
set "_TEMPDIRS=0"
:: Determine which KitsRoot10 registry key exists
set "REG_KEY_PATH_FOUND=1"
set "WOW_REG_KEY_PATH_FOUND=1"
reg.exe query "HKLM\Software\Wow6432Node\Microsoft\Windows Kits\Installed Roots" /v KitsRoot10 %_NULL% || set "WOW_REG_KEY_PATH_FOUND=0"
reg.exe query "HKLM\Software\Microsoft\Windows Kits\Installed Roots" /v KitsRoot10 %_NULL% || set "REG_KEY_PATH_FOUND=0"
if %WOW_REG_KEY_PATH_FOUND% EQU 0 (
if %REG_KEY_PATH_FOUND% EQU 0 (
goto PRECHECK
) else (
set "REG_KEY_PATH=HKLM\Software\Microsoft\Windows Kits\Installed Roots"
)
) else (
set "REG_KEY_PATH=HKLM\Software\Wow6432Node\Microsoft\Windows Kits\Installed Roots"
)
for /f "skip=2 tokens=2*" %%I in ('reg.exe query "%REG_KEY_PATH%" /v KitsRoot10') do (
set "KITS_ROOT=%%J"
)
set "DANDIRoot=%KITS_ROOT%Assessment and Deployment Kit\Deployment Tools"
if exist "%DANDIRoot%\%X_OS%\DISM\dism.exe" (
set "PATH=%DANDIRoot%\%X_OS%\DISM;%SYS_PATH%;%SystemRoot%;%SYS_PATH%\Wbem;%SYS_PATH%\WindowsPowerShell\v1.0\"
cd \
)
:: =============================== BEGIN PRECHECKS ===============================
:PRECHECK
echo.
echo.
choice /C YN /N /M "Detect and cleanup any mounted directories? [y/n]: "
set "_ER=%ERRORLEVEL%"
if %_ER% EQU 2 goto CHECK2
if %_ER% EQU 1 set "_MOUNTED=1"&goto CHECK2
goto PRECHECK
:CHECK2
set "_ER=0"
echo.
echo.
choice /C YN /N /M "Detect and remove any W10UI* temporary directories? [y/n]: "
set "_ER=%ERRORLEVEL%"
if %_ER% EQU 2 (
if %_MOUNTED% EQU 1 goto ALL
goto :eof
)
if %_ER% EQU 1 set "_TEMPDIRS=1"&goto ALL
goto CHECK2
:: =============================== MAIN ACTIONS ===============================
:ALL
cls
if %_MOUNTED% EQU 0 goto TEMP_DIRS
for /f "tokens=3*" %%A in ('
reg.exe query "%_KEY%" /s /v "Mount Path" 2^>nul ^| findstr /i /c:"Mount Path"
') do (
set "_MOUNT=%%B"
call :CLN
)
dism.exe /English /Cleanup-Wim
dism.exe /English /Cleanup-Mountpoints
if %_TEMPDIRS% EQU 1 goto TEMP_DIRS
goto THE_END
:TEMP_DIRS
echo.
echo Removing W10UI* directories
for %%D in (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 (
if exist "%%D:\W10UIuup\" (set "_MOUNT=%%D:\W10UIuup" & call :TMP)
if exist "%%D:\W10MUITEMP\" (set "_MOUNT=%%D:\W10MUITEMP" & call :TMP)
if exist "%%D:\W10UItemp\" (set "_MOUNT=%%D:\W10UItemp" & call :TMP)
for /f %%A in ('dir /b /ad "%%D:\W10UItemp_*" 2^>nul') do (
set "_MOUNT=%%D:\%%A"
call :TMP
)
)
goto THE_END
:: =============================== SUBROUTINES ===============================
:CLN
dism.exe /English /Image:"%_MOUNT%" /Get-Packages %_NULL%
dism.exe /English /Unmount-Wim /MountDir:"%_MOUNT%" /Discard
exit /b
:TEMP
:: (kept only if you referenced it previously; main uses :TMP below)
exit /b
:TMP
if exist "%_MOUNT%\" (
rmdir /s /q "%_MOUNT%\" %_NULL%
)
if exist "%_MOUNT%" (
mkdir "%_DRV%\_del286" %_NULL%
robocopy "%_DRV%\_del286" "%_MOUNT%" /MIR /R:1 /W:1 /NFL /NDL /NP /NJH /NJS %_NULL%
rmdir /s /q "%_DRV%\_del286\" %_NULL%
rmdir /s /q "%_MOUNT%" %_NULL%
)
exit /b
:: =============================== END ===============================
:THE_END
echo.
echo Press any key to exit.
pause >nul
goto :eof
:: =============================== COMPONENTS (BIG COMMENT) ===============================
:: 1) Argument parsing + relaunch:
:: - Reads %* into _ARGS and checks for -WOW and -ARM flags.
:: - If running in the wrong cmd context, re-launches itself using Sysnative/SysArm32 cmd.exe,
:: passing the original script path and required flag.
;;
:: 2) Environment setup:
:: - Builds a _NULL redirection string (silent output).
:: - Sets SYS_PATH/PATH so DISM/PowerShell tools resolve correctly.
;;
:: 3) Admin requirement:
:: - Uses whoami /groups and checks for admin SIDs.
:: - If not elevated, prints a message and exits.
;;
:: 4) Architecture handling:
:: - Computes X_OS (PROCESSOR_ARCHITECTURE with x86/WOW64 correction).
:: - Finds the Windows Assessment/DISM tool path under the KitsRoot10 registry key.
;;
:: 5) User prompts:
:: - PRECHECK: ask whether to detect/cleanup mounted WIM directories.
:: - CHECK2 : ask whether to remove temporary W10UI* directories.
;;
:: 6) Cleanup logic:
:: - ALL:
:: a) If mounted cleanup is enabled:
:: - Reads Mount Path values from HKLM\SOFTWARE\Microsoft\WIMMount\Mounted Images
:: and for each mount dir calls :CLN.
:: - Runs DISM cleanup commands.
:: b) If temp cleanup is enabled:
:: - Loops all drive letters C-Z and checks for:
:: W10UIuup, W10MUITEMP, W10UItemp, and W10UItemp_* folders.
:: - For each found folder calls :TMP to delete safely.
;;
:: 7) Subroutines:
:: - :CLN unmounts the mounted image (and gets packages first).
:: - :TMP removes the directory; if it still exists, uses a robocopy-based delete pattern
:: through %_DRV%\_del286 to force removal.
;;
:: 8) Exit:
:: - THE_END pauses so the console stays open briefly, then terminates.
@echo off
:: Generated on 2026-08-16 09:09:41 GMT
:: =============================== COMPONENTS (BIG COMMENT) ===============================
:: 1) Working directory + path safety:
:: - cd /d "%~dp0" to run from script folder.
:: - Checks whether the folder path contains a space and exits early if it does.
;;
:: 2) Admin relaunch:
:: - If already running as admin (HKU\S-1-5-19\Environment exists), jumps to START_PROCESS.
:: - Otherwise, builds a command string that re-launches this script elevated via PowerShell.
:: - If the relaunch fails, prints an admin-required message and pauses.
;;
:: 3) START_PROCESS download workflow:
:: - Sets tool paths (aria2c, 7zr, uup-converter archive) and output dirs.
:: - Runs a PowerShell helper (get_aria2.ps1) to fetch aria2c if missing.
:: - Downloads converter assets via aria2 using the provided UUP dump “converter_windows” script input.
:: - Validates required local files exist; exits if any are missing.
;;
:: 4) Extract + download UUP content:
:: - Extracts ConvertConfig.ini + CustomAppsList.txt from 7zr archive.
:: - Downloads Microsoft Store apps UUP via aria2 using a generated random aria2 script file.
:: - Downloads the “he-il” / professional UUP set similarly.
:: - Detects failures by parsing #UUPDUMP_ERROR: lines in the aria2 script output.
;;
:: 5) Optional conversion:
:: - If convert-UUP.cmd exists, it is called.
;;
:: 6) Error handlers + exit:
:: - Named labels for missing files and download errors; pauses then exits.
:: ============================================================================
cd /d "%~dp0"
if NOT "%cd%"=="%cd: =%" (
echo Current directory contains spaces in its path.
echo Please move or rename the directory to one not containing spaces.
echo.
pause
goto :EOF
)
set "_SCRIPT_ID=49127c4b-02dc-482e-ac4f-ec4d659b7547"
:: Admin check gate
reg QUERY HKU\S-1-5-19\Environment >NUL 2>&1 && goto :START_PROCESS
if "[%1]"=="[%_SCRIPT_ID%]" goto :START_PROCESS
:: Relaunch elevated through PowerShell
set "CMD_ELEVATE="""%~f0""" %_SCRIPT_ID%"
setlocal EnableDelayedExpansion
set "CMD_ELEVATE=!CMD_ELEVATE:'=''!"
powershell -NoProfile Start-Process -FilePath "%COMSPEC%" ^
-ArgumentList "/c ""!CMD_ELEVATE!""" -Verb RunAs 2>NUL
endlocal
if %ERRORLEVEL% GTR 0 (
echo =====================================================
echo This script needs to be executed as an administrator.
echo =====================================================
echo.
pause
)
goto :EOF
:START_PROCESS
title 28000.2704_amd64_he-il_professional_312f676b download
set "ARIA2_EXE=files\aria2c.exe"
set "7ZR_EXE=files\7zr.exe"
set "UUP_CONV_7Z=files\uup-converter-wimlib.7z"
set "ARIA2_SCRIPT=files\aria2_script.%RANDOM%.txt"
set "DEST_DIR=UUPs"
powershell -NoProfile -ExecutionPolicy Unrestricted ".\files\get_aria2.ps1" || (
pause
exit /b 1
)
echo.
echo Downloading the UUP converter...
"%ARIA2_EXE%" --no-conf --async-dns=false --console-log-level=warn --log-level=info --log="aria2_download.log" ^
-x16 -s16 -j2 -c -R -d"files" -i"files\converter_windows"
if %ERRORLEVEL% GTR 0 goto :DOWNLOAD_CONVERTER_ERROR
echo.
if NOT EXIST "ConvertConfig.ini" goto :NO_FILE_ERROR
if NOT EXIST "CustomAppsList.txt" goto :NO_FILE_ERROR
if NOT EXIST "%7ZR_EXE%" goto :NO_FILE_ERROR
if NOT EXIST "%UUP_CONV_7Z%" goto :NO_FILE_ERROR
echo Extracting UUP converter...
"%7ZR_EXE%" -x"!ConvertConfig.ini" -x"!CustomAppsList.txt" -y x "%UUP_CONV_7Z%" >NUL
echo.
:DOWNLOAD_APPS
echo Retrieving aria2 script for Microsoft Store Apps...
"%ARIA2_EXE%" --no-conf --async-dns=false --console-log-level=warn --log-level=info --log="aria2_download.log" ^
-o"%ARIA2_SCRIPT%" --allow-overwrite=true --auto-file-renaming=false ^
"https://uupdump.net/get.php?id=312f676b-2cbe-41aa-ba85-85c09c88518c&pack=neutral&edition=app&aria2=2"
if %ERRORLEVEL% GTR 0 goto :DOWNLOAD_ERROR
echo.
set "DETECTED_ERROR="
for /F "tokens=2 delims=:" %%I in ('findstr #UUPDUMP_ERROR: "%ARIA2_SCRIPT%"') do set "DETECTED_ERROR=%%I"
if NOT "[%DETECTED_ERROR%]"=="[]" (
echo Unable to retrieve data from Windows Update servers. Reason: %DETECTED_ERROR%
echo If this problem persists, most likely the set you are attempting to download was removed from Windows Update servers.
echo.
pause
goto :EOF
)
echo Downloading Microsoft Store Apps...
"%ARIA2_EXE%" --no-conf --async-dns=false --console-log-level=warn --log-level=info --log="aria2_download.log" ^
-x16 -s16 -j25 -c -R -d"%DEST_DIR%" -i"%ARIA2_SCRIPT%"
if %ERRORLEVEL% GTR 0 goto :DOWNLOAD_APPS
echo.
:DOWNLOAD_UUPS
echo Retrieving aria2 script for the UUP set...
"%ARIA2_EXE%" --no-conf --async-dns=false --console-log-level=warn --log-level=info --log="aria2_download.log" ^
-o"%ARIA2_SCRIPT%" --allow-overwrite=true --auto-file-renaming=false ^
"https://uupdump.net/get.php?id=312f676b-2cbe-41aa-ba85-85c09c88518c&pack=he-il&edition=professional&aria2=2"
if %ERRORLEVEL% GTR 0 goto :DOWNLOAD_ERROR
echo.
set "DETECTED_ERROR="
for /F "tokens=2 delims=:" %%I in ('findstr #UUPDUMP_ERROR: "%ARIA2_SCRIPT%"') do set "DETECTED_ERROR=%%I"
if NOT "[%DETECTED_ERROR%]"=="[]" (
echo Unable to retrieve data from Windows Update servers. Reason: %DETECTED_ERROR%
echo If this problem persists, most likely the set you are attempting to download was removed from Windows Update servers.
echo.
pause
goto :EOF
)
echo Downloading the UUP set...
"%ARIA2_EXE%" --no-conf --async-dns=false --console-log-level=warn --log-level=info --log="aria2_download.log" ^
-x16 -s16 -j5 -c -R -d"%DEST_DIR%" -i"%ARIA2_SCRIPT%"
if %ERRORLEVEL% GTR 0 goto :DOWNLOAD_UUPS
echo.
if EXIST "convert-UUP.cmd" call :START_CONVERT
goto :EOF
:START_CONVERT
call convert-UUP.cmd
goto :EOF
:NO_FILE_ERROR
echo We couldn't find one of needed files for this script.
pause
goto :EOF
:DOWNLOAD_CONVERTER_ERROR
echo.
echo An error has occurred while downloading the UUP converter.
pause
goto :EOF
:DOWNLOAD_ERROR
echo.
echo We have encountered an error while downloading files.
pause
goto :EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment