-
Notifications
You must be signed in to change notification settings - Fork 7
/
Simple-WIM2ESD---ESD2WIM-Converter.bat
508 lines (464 loc) · 18.5 KB
/
Simple-WIM2ESD---ESD2WIM-Converter.bat
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
@ECHO off
setlocal EnableDelayedExpansion
TITLE Simple WIM2ESD / ESD2WIM Converter - By Joel Didier (Studisys)
:: Set DISM Directory
CD /d "%~dp0"
IF EXIST "%CD%\DISM\dism.exe" SET DISM_PATH="%CD%\DISM"
GOTO AdminRightsRoutine
:AdminRightsRoutine
IF "%PROCESSOR_ARCHITECTURE%" EQU "amd64" (
>NUL 2>&1 "%SYSTEMROOT%\SysWOW64\caCLS.exe" "%SYSTEMROOT%\SysWOW64\config\system"
) ELSE (
>NUL 2>&1 "%SYSTEMROOT%\system32\caCLS.exe" "%SYSTEMROOT%\system32\config\system"
)
IF '%ERRORLEVEL%' NEQ '0' (
GOTO GetAdminRights
) ELSE ( GOTO GetAdminRightsSuccess )
:GetAdminRights
CLS
COLOR 17
ECHO.
ECHO. ================================================================
ECHO. Simple WIM2ESD / ESD2WIM Converter
ECHO. Administrator Rights Required
ECHO. ================================================================
ECHO.
ECHO.
ECHO. You did not execute the script as Administrator.
ECHO. Administrator rights are required.
ECHO. You will now be prompted for Administrator rights.
ECHO. If you do not grant Administrator rights, this script will not run.
ECHO.
PAUSE
ECHO Set UAC = CreateObject^("Shell.Application"^) > "%temp%\GetAdminRights.vbs"
SET params = %*:"=""
ECHO UAC.ShellExecute "cmd.exe", "/c ""%~s0"" %params%", "", "runas", 1 >> "%temp%\GetAdminRights.vbs"
"%temp%\GetAdminRights.vbs"
DEL "%temp%\GetAdminRights.vbs"
EXIT /B
:GetAdminRightsSuccess
pushd "%CD%"
CD /D "%~dp0"
GOTO Home
:Home
CLS
COLOR 17
ECHO.
ECHO. ================================================================
ECHO. Simple WIM2ESD / ESD2WIM Converter
ECHO. Welcome
ECHO. ================================================================
ECHO.
ECHO.
ECHO. Welcome to the Simple WIM2ESD / ESD2WIM Converter (version 0.5.0-beta)
ECHO.
ECHO. This tool allows to quickly convert a WIM Image to an ESD Image, and vice-versa.
ECHO.
ECHO. Please read the full documentation on :
ECHO. https://github.com/Studisys/Simple-WIM2ESD---ESD2WIM-Converter/
ECHO.
ECHO.
PAUSE
CALL :CheckVariables
:CheckVariables
CALL :CONVERSIONTYPE
CALL :SRCPATHSET
CALL :DSTPATHSET
CALL :COMPRESSTYPESET
GOTO IndexExport
:CONVERSIONTYPE
CLS
ECHO.
ECHO. ================================================================
ECHO. Simple WIM2ESD / ESD2WIM Converter
ECHO. Program Parameters
ECHO. Conversion Type
ECHO. ================================================================
ECHO.
ECHO.
ECHO. What type of conversion do you want ?
ECHO.
ECHO. [1] WIM --^> ESD
ECHO. [2] ESD --^> WIM
ECHO.
ECHO. ================================================================
ECHO. Press 'Q' to exit, 'S' to start over
ECHO. ================================================================
ECHO.
CHOICE /c 12qs /n /m " Your choice : "
IF %ERRORLEVEL%==1 CALL :WIMESDPRESET
IF %ERRORLEVEL%==2 CALL :ESDWIMPRESET
IF %ERRORLEVEL%==3 EXIT
IF %ERRORLEVEL%==4 GOTO AdminRightsRoutine
GOTO SETVAR
:WIMESDPRESET
SET SRCtype=WIM
SET DSTtype=ESD
SET SRC_PATH=install.wim
SET DST_PATH=install.esd
SET COMPRESS_TYPE=Recovery
GOTO :eof
:ESDWIMPRESET
SET SRCtype=ESD
SET DSTtype=WIM
SET SRC_PATH=install.esd
SET DST_PATH=install.wim
SET COMPRESS_TYPE=Recovery
GOTO :eof
:SETVAR
CALL :SRCPATH
GOTO IndexExport
:SRCPATH
CLS
ECHO.
ECHO. ================================================================
ECHO. Simple WIM2ESD / ESD2WIM Converter
ECHO. %SRCtype% --^> %DSTtype%
ECHO. Path to Source Image
ECHO. ================================================================
ECHO.
ECHO.
ECHO. Current Path to the source Image is : %SRC_PATH%
ECHO. Do you wish to change it ?
ECHO.
ECHO. [Y] Yes
ECHO. [N] No
ECHO.
ECHO. ================================================================
ECHO. Press 'Q' to exit, 'S' to start over
ECHO. ================================================================
ECHO.
CHOICE /c ynqs /n /m "Your choice : "
IF %ERRORLEVEL%==1 CALL :SRCPATHSET
IF %ERRORLEVEL%==2 GOTO DSTPATH
IF %ERRORLEVEL%==3 EXIT
IF %ERRORLEVEL%==4 GOTO AdminRightsRoutine
GOTO DSTPATH
:SRCPATHSET
CLS
ECHO.
ECHO. ================================================================
ECHO. Simple WIM2ESD / ESD2WIM Converter
ECHO. %SRCtype% --^> %DSTtype%
ECHO. Path to Source Image
ECHO. ================================================================
ECHO.
ECHO.
ECHO. Please enter the path to the source image.
ECHO. (Do not include quotes "")
ECHO.
SET /P c= Path :
SET SRC_PATH=%c%
GOTO :eof
:DSTPATH
CLS
ECHO.
ECHO. ================================================================
ECHO. Simple WIM2ESD / ESD2WIM Converter
ECHO. %SRCtype% --^> %DSTtype%
ECHO. Path to Destination Image
ECHO. ================================================================
ECHO.
ECHO.
ECHO. Current Path to the destination Image is : %DST_PATH%
ECHO. Do you wish to change it ?
ECHO.
ECHO. [Y] Yes
ECHO. [N] No
ECHO.
ECHO. ================================================================
ECHO. Press 'Q' to exit, 'S' to start over
ECHO. ================================================================
ECHO.
CHOICE /c ynqs /n /m "Your choice : "
IF %ERRORLEVEL%==1 CALL :DSTPATHSET
IF %ERRORLEVEL%==2 GOTO COMPRESSTYPE
IF %ERRORLEVEL%==3 EXIT
IF %ERRORLEVEL%==4 GOTO AdminRightsRoutine
GOTO COMPRESSTYPE
:DSTPATHSET
CLS
ECHO.
ECHO. ================================================================
ECHO. Simple WIM2ESD / ESD2WIM Converter
ECHO. %SRCtype% --^> %DSTtype%
ECHO. Path to Destination Image
ECHO. ================================================================
ECHO.
ECHO.
ECHO. Please enter the path to the destination image.
ECHO. (Do not include quotes "")
ECHO.
SET /P c= Path :
SET DST_PATH=%c%
GOTO :eof
:COMPRESSTYPE
CLS
ECHO.
ECHO. ================================================================
ECHO. Simple WIM2ESD / ESD2WIM Converter
ECHO. %SRCtype% --^> %DSTtype%
ECHO. Compress Type
ECHO. ================================================================
ECHO.
ECHO.
ECHO. Current Compression Type is : %COMPRESS_TYPE%
ECHO. Do you wish to change it ?
ECHO.
ECHO. [Y] Yes
ECHO. [N] No
ECHO.
ECHO. ================================================================
ECHO. Press 'Q' to exit, 'S' to start over
ECHO. ================================================================
ECHO.
CHOICE /c ynqs /n /m "Your choice : "
IF %ERRORLEVEL%==1 CALL :COMPRESSTYPESET
IF %ERRORLEVEL%==2 GOTO IndexAnalyzer
IF %ERRORLEVEL%==3 EXIT
IF %ERRORLEVEL%==4 GOTO AdminRightsRoutine
GOTO IndexAnalyzer
:COMPRESSTYPESET
CLS
ECHO.
ECHO. ================================================================
ECHO. Simple WIM2ESD / ESD2WIM Converter
ECHO. %SRCtype% --^> %DSTtype%
ECHO. Compress Type
ECHO. ================================================================
ECHO.
ECHO.
ECHO. Please enter the compression type.
ECHO.
ECHO. Available Compression Types :
ECHO.
ECHO. [1] None : No Compression (Fastest) [Destination Image bigger than Source Image]
ECHO.
ECHO. [2] Fast : Low Compression (Fast) [Destination Image 'may' be bigger than Source Image]
ECHO.
ECHO. [3] Maximum : Very High Compression (Slow) [Destination Image WAY smaller than Source Image]
ECHO.
ECHO. [4] Recovery : Insane Compression (Slowest) [Destination Image WAY smaller than Source Image]
ECHO.
ECHO.
ECHO. ================================================================
ECHO. Press 'Q' to exit, 'S' to start over
ECHO. ================================================================
ECHO.
CHOICE /c 1234qs /n /m "Your choice : "
IF %ERRORLEVEL%==1 (
SET COMPRESS_TYPE=None
)
IF %ERRORLEVEL%==2 (
SET COMPRESS_TYPE=Fast
)
IF %ERRORLEVEL%==3 (
SET COMPRESS_TYPE=Maximum
)
IF %ERRORLEVEL%==4 (
SET COMPRESS_TYPE=Recovery
)
IF %ERRORLEVEL%==5 EXIT
IF %ERRORLEVEL%==6 GOTO AdminRightsRoutine
GOTO IndexAnalyzer
:IndexAnalyzer
CLS
ECHO. ================================================================
ECHO. Simple WIM2ESD / ESD2WIM Converter
ECHO. %SRCtype% --^> %DSTtype%
ECHO. Analyzing %SRCtype% . . .
ECHO. ================================================================
ECHO.
setlocal EnableDelayedExpansion
SET /A count=0
FOR /F "tokens=2 delims=: " %%i IN ('DISM /Get-WimInfo /WimFile:"%SRC_PATH%" ^| findstr "Index"') DO SET images=%%i
IF %ERRORLEVEL% NEQ 0 GOTO ERROR
FOR /L %%i in (1, 1, %images%) DO CALL :IndexCounter %%i
ECHO. The %SRCtype% Image contains the following %images% indexes :
ECHO.
FOR /L %%i in (1, 1, %images%) DO (
ECHO. [%%i] !name%%i!
)
ECHO.
ECHO. ================================================================
ECHO.
ECHO. What do you want to do ?
ECHO.
ECHO. [1] Export a single Index
ECHO. [2] Export all Indexes
ECHO. ================================================================
ECHO. Press 'Q' to exit, 'S' to start over
ECHO. ================================================================
ECHO.
CHOICE /c 12qs /n /m "Your choice : "
IF %ERRORLEVEL%==1 GOTO ExportSingleIndex
IF %ERRORLEVEL%==2 GOTO ExportAllIndex
IF %ERRORLEVEL%==3 EXIT
IF %ERRORLEVEL%==4 GOTO AdminRightsRoutine
:IndexCounter
SET /A count+=1
FOR /f "tokens=1* delims=: " %%i IN ('DISM /Get-WimInfo /wimfile:"%SRC_PATH%" /index:%1 ^| find /i "Name"') DO SET name%count%=%%j
IF %ERRORLEVEL% NEQ 0 GOTO ERROR
GOTO :eof
:DEL_DST_PATH
IF EXIST %DST_PATH% (
DEL /F %DST_PATH%
)
GOTO :eof
:ExportSingleIndex
CLS
ECHO. ================================================================
ECHO. Simple WIM2ESD / ESD2WIM Converter
ECHO. %SRCtype% --^> %DSTtype%
ECHO. Export Single Index
ECHO. ================================================================
ECHO.
ECHO. Please enter the Index number you want to export.
ECHO.
ECHO. Here are the Indexes :
ECHO.
FOR /L %%i IN (1, 1, %images%) DO (
ECHO. [%%i] !name%%i!
)
ECHO.
ECHO.
SET /P INDEXCHOICE= Your choice :
CLS
ECHO. ================================================================
ECHO. Simple WIM2ESD / ESD2WIM Converter
ECHO. %SRCtype% --^> %DSTtype%
ECHO. ================================================================
ECHO.
ECHO. This will export Index %INDEXCHOICE% to the destination %DSTtype% Image.
ECHO.
ECHO. PLEASE NOTE :
ECHO. This operation may take a few minutes to complete depending on your PC Hardware.
ECHO. This operation will use a lot of CPU and Memory ressources.
ECHO. Your system may be hotter or may seem unresponsive while processing your request.
ECHO. Please do not interfer with the process before it has ended.
ECHO.
ECHO.
ECHO. ================================================================
ECHO. Simple WIM2ESD / ESD2WIM Converter
ECHO. Export Single Index
ECHO. Exporting Index %INDEXCHOICE% . . .
ECHO. ================================================================
ECHO.
ECHO.
CALL :DEL_DST_PATH
"%DISM_PATH%"\DISM /Export-Image /SourceImageFile:"%SRC_PATH%" /Sourceindex:%INDEXCHOICE% /DestinationImageFile:"%DST_PATH%" /compress:%COMPRESS_TYPE% /CheckIntegrity
IF %ERRORLEVEL% NEQ 0 GOTO ERROR
GOTO SUCCESS
:ExportAllIndex
CLS
TITLE Simple WIM2ESD / ESD2WIM Converter - %SRCtype%2%DSTtype% - Exporting Index 1 / %images% . . .
ECHO. ================================================================
ECHO. Simple WIM2ESD / ESD2WIM Converter
ECHO. %SRCtype% --^> %DSTtype%
ECHO. ================================================================
ECHO.
ECHO. This will export all indexes to the destination %DSTtype% Image.
ECHO.
ECHO. PLEASE NOTE :
ECHO. This operation may take a few minutes to complete depending on your PC Hardware.
ECHO. This operation will use a lot of CPU and Memory ressources.
ECHO. Your system may be hotter or may seem unresponsive while processing your request.
ECHO. Please do not interfer with the process before it has ended.
ECHO.
ECHO.
ECHO. ================================================================
ECHO. Simple WIM2ESD / ESD2WIM Converter
ECHO. Exporting All Indexes
ECHO. Exporting Index 1 of %images% . . .
ECHO. ================================================================
ECHO.
ECHO.
CALL :DEL_DST_PATH
"%DISM_PATH%"\DISM /Export-Image /SourceImageFile:"%SRC_PATH%" /Sourceindex:1 /DestinationImageFile:"%DST_PATH%" /compress:%COMPRESS_TYPE% /CheckIntegrity
IF %ERRORLEVEL% NEQ 0 GOTO ERROR
FOR /L %%i IN (2, 1, %images%) DO (
CLS
TITLE %SRCtype%2%DSTtype% - Exporting Index %%i / %images% . . .
ECHO. ================================================================
ECHO. Simple WIM2ESD / ESD2WIM Converter
ECHO. %SRCtype% --^> %DSTtype%
ECHO. ================================================================
ECHO.
ECHO. This will export all indexes to the destination %DSTtype% Image.
ECHO.
ECHO. PLEASE NOTE :
ECHO. This operation may take a few minutes to complete depending on your PC Hardware.
ECHO. This operation will use a lot of CPU and Memory ressources.
ECHO. Your system may be hotter or may seem unresponsive while processing your request.
ECHO. Please do not interfer with the process before it has ended.
ECHO.
ECHO.
ECHO. ================================================================
ECHO. Simple WIM2ESD / ESD2WIM Converter
ECHO. Exporting All Indexes . . .
ECHO. Exporting Index %%i of %images% . . .
ECHO. ================================================================
ECHO.
ECHO.
"%DISM_PATH%"\DISM /Export-Image /SourceImageFile:"%SRC_PATH%" /SourceIndex:%%i /DestinationImageFile:"%DST_PATH%" /Compress:%COMPRESS_TYPE% /CheckIntegrity
)
IF %ERRORLEVEL% NEQ 0 GOTO ERROR
GOTO SUCCESS
:SUCCESS
CLS
COLOR 17
ECHO.
ECHO. ================================================================
ECHO. Simple WIM2ESD / ESD2WIM Converter
ECHO. Success
ECHO. ================================================================
ECHO.
ECHO. Successfully performed requested tasks.
ECHO.
ECHO. Thanks for using my script.
ECHO. GitHub Page : https://github.com/Studisys/Simple-WIM2ESD---ESD2WIM-Converter/
ECHO. Version : 0.5.0-beta
ECHO. Author : Joel Didier (Studisys)
ECHO. Twitter : https://twitter.com/Studisys
ECHO. Email : studisys@protonmail.com
ECHO.
ECHO. ================================================================
ECHO. Press 'Q' to exit, 'S' to start over
ECHO. ================================================================
ECHO.
CHOICE /c qs /n /m ""
IF %ERRORLEVEL%==1 EXIT
IF %ERRORLEVEL%==2 GOTO AdminRightsRoutine
EXIT
:ERROR
COLOR 17
ECHO.
ECHO. ================================================================
ECHO. Simple WIM2ESD Converter
ECHO. Error
ECHO. ================================================================
ECHO.
ECHO. Something wrong occured . . .
ECHO.
ECHO. Currently, there is no log, except the one generated from DISM.
ECHO. This script will generate a complete log in the future.
ECHO. Please send me the error given by DISM and the log located in :
ECHO. C:\WINDOWS\Logs\DISM\dism.log
ECHO.
ECHO.
ECHO. Thanks in advance.
ECHO.
ECHO. GitHub Page : https://github.com/Studisys/Simple-WIM2ESD---ESD2WIM-Converter/
ECHO.
ECHO. Author : Joel Didier (Studisys)
ECHO. Twitter : https://twitter.com/Studisys
ECHO. Email : studisys@protonmail.com
ECHO.
ECHO. ================================================================
ECHO. Press 'Q' to exit, 'S' to start over
ECHO. ================================================================
ECHO.
CHOICE /c qs /n /m ""
IF %ERRORLEVEL%==1 EXIT
IF %ERRORLEVEL%==2 GOTO AdminRightsRoutine
EXIT