-
Notifications
You must be signed in to change notification settings - Fork 258
/
Copy pathesd2cab_GUI.cmd
53 lines (51 loc) · 1.78 KB
/
esd2cab_GUI.cmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
@echo off
title ESD -^> CAB
cd /d "%~dp0"
if /i "%PROCESSOR_ARCHITECTURE%" equ "AMD64" (set "arch=x64") else (set "arch=x86")
for %%A in (image%arch%.exe,DXTool_%arch%.exe,SxSExpand.exe) do (
if not exist "bin\%%A" (set "MESSEGE=%%A is not detected."&goto :fin)
)
if not exist "*.esd" (set "MESSEGE=No .esd files detected."&goto :fin)
for %%p in ("bin\image%arch%.exe") do set "IMAGEX=%%~fp"
for %%p in ("bin\DXTool_%arch%.exe") do set "DXTOOL=%%~fp"
for %%p in ("bin\SxSExpand.exe") do set "SXS=%%~fp"
set "tempdir=temp%random%"
for /f "delims=" %%i in ('dir /b /a:-d *.esd') do call :esdcab "%%i"
set "MESSEGE=Done."
goto :fin
:esdcab
set "pack=%~n1"
if exist "%pack%.cab" goto :eof
echo.
echo ============================================================
echo Expand: %pack%.esd
echo ============================================================
rd /s /q "%tempdir%" >nul 2>&1
md "%tempdir%"
"%IMAGEX%" /APPLY "%~1" 1 "%tempdir%" /NOACL ALL /NOTADMIN /TEMP "%temp%" >nul
SET ERRORTEMP=%ERRORLEVEL%
IF %ERRORTEMP% NEQ 0 (set "MESSEGE=Errors were reported during process."&goto :fin)
echo.
echo ============================================================
echo Create: %pack%.cab
echo ============================================================
pushd "%tempdir%"
md _sxs
for /f %%a in ('dir /b /a:-d *.manifest') do ("%SXS%" %%a _sxs\%%a >nul)
if exist "_sxs\*.manifest" move /y _sxs\* . >nul
rd /s /q _sxs\
popd
start /HIGH /WAIT "" "%DXTOOL%" /CT "%tempdir%"
ren %tempdir%.cab %pack%.cab
rd /s /q "%tempdir%" >nul 2>&1
goto :eof
:fin
rd /s /q "%tempdir%" >nul 2>&1
echo.
echo ============================================================
echo %MESSEGE%
echo ============================================================
echo.
echo Press any key to exit...
pause >nul
exit