-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploid.cmd
1047 lines (1047 loc) · 76.9 KB
/
deploid.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
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
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
::d e p l o i d 1.0 (C) Joshua Cline - All rights reserved
@ECHO OFF&&SETLOCAL ENABLEDELAYEDEXPANSION&&CHCP 437>NUL&&SET "VER_GET=%0"&&CALL:VER_GET&&SET "ORIG_CD=%CD%"&&CD /D "%~DP0"
Reg.exe query "HKU\S-1-5-19\Environment">NUL
IF NOT "%ERRORLEVEL%" EQU "0" ECHO.Right-Click ^& Run As Administrator&&PAUSE&&GOTO:QUIT
FOR /F "TOKENS=*" %%a in ('ECHO.%CD%') DO (SET "CAPS_SET=PROG_FOLDER"&&SET "CAPS_VAR=%%a"&&CALL:CAPS_SET)
SET "CHAR_STR=%PROG_FOLDER%"&&SET "CHAR_CHK= "&&CALL:CHAR_CHK
IF DEFINED CHAR_FLG ECHO.ERROR: Remove the space from the path or folder name, then launch again.&&PAUSE&&GOTO:QUIT
IF "%PROG_FOLDER%"=="%SYSTEMDRIVE%\WINDOWS\SYSTEM32" ECHO.ERROR: Invalid path or folder name. Relocate, then launch again.&&PAUSE&&GOTO:QUIT
FOR /F "TOKENS=1-9 DELIMS=\" %%a IN ("%PROG_FOLDER%") DO (IF "%%a\%%b\%%c"=="%SystemDrive%\WINDOWS\TEMP" SET "PATH_FAIL=1"
IF "%%a\%%b\%%d\%%e\%%f"=="%SystemDrive%\USERS\APPDATA\LOCAL\TEMP" SET "PATH_FAIL=1")
IF DEFINED PATH_FAIL ECHO.ERROR: This should not be run from a temp folder. Extract zip into a new folder, then launch again.&&PAUSE&&GOTO:QUIT
IF "%PROG_FOLDER%"=="X:\$" IF "%SystemDrive%"=="X:" SET "WINPE_BOOT=1"
FOR /F "TOKENS=1 DELIMS=: " %%a IN ('DISM') DO (IF "%%a"=="Examples" SET "LANG_PASS=1")
IF NOT DEFINED LANG_PASS ECHO.ERROR: Non-english host language/locale.&&GOTO:QUIT
IF NOT "%PROG_FOLDER%"=="X:\$" SET "PROG_MODE=PORTABLE"&&CALL:SETS_HANDLER&GOTO:BASIC_CREATOR
IF "%PROG_FOLDER%"=="X:\$" IF "%SystemDrive%"=="X:" SET "PROG_MODE=RAMDISK"&&COLOR 0B
IF "%PROG_FOLDER%"=="X:\$" IF NOT "%SystemDrive%"=="X:" ECHO.ERROR: Relocate to path other than X:\$.&&GOTO:QUIT
IF EXIST "%PROG_FOLDER%\RECOVERY_LOCK" CALL:RECOVERY_LOCK
IF DEFINED LOCKOUT GOTO:QUIT
REG.EXE DELETE "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\MiniNT" /f>NUL 2>&1
CALL:HOST_AUTO&CALL:SETS_HANDLER
:MAIN_MENU
@ECHO OFF&&CLS&&CALL:SETS_HANDLER&&CALL:CLEAN&&CALL:FREE_CALC&&CALL:PAD_LINE&&CALL:BOXT1&&ECHO. deploid Recovery Environment&&ECHO.&&ECHO. (%##%1%#$%) Backup&&ECHO. (%##%2%#$%) Restore&&ECHO. (%##%3%#$%) Boot Creator&&ECHO. (%##%.%#$%) Change Boot Order&&ECHO.&&CALL:BOXB1&&CALL:PAD_LINE&&TITLE deploid v%VER_CUR% (%PROG_SOURCE%)
IF DEFINED HOST_ERROR ECHO. %XLR2%Disk Error%#$% UID %#@%%HOST_TARGET%%#$%&&CALL:PAD_LINE
ECHO. (%##%Q%#$%)uit (%##%*%#$%) Settings %#@%%FREE%GB%#$% Free&&CALL:PAD_LINE&&CALL:MENU_SELECT
IF "%SELECT%"=="Q" GOTO:QUIT
IF "%SELECT%"=="CMD" START CMD.EXE
IF DEFINED HOST_ERROR GOTO:MAIN_MENU
IF "%SELECT%"=="." CALL:BCD_MENU&SET "SELECT="
IF "%SELECT%"=="1" CALL:BASIC_BACKUP&SET "SELECT="
IF "%SELECT%"=="2" CALL:BASIC_RESTORE&SET "SELECT="
IF "%SELECT%"=="3" GOTO:BASIC_CREATOR&SET "SELECT="
IF "%SELECT%"=="*" GOTO:SETTINGS_MENU&SET "SELECT="
GOTO:MAIN_MENU
:PAD_LINE
IF NOT DEFINED PAD_TYPE SET "PAD_TYPE=1"
IF NOT DEFINED ACC_COLOR SET "ACC_COLOR=6"
IF NOT DEFINED BTN_COLOR SET "BTN_COLOR=7"
IF NOT DEFINED TXT_COLOR SET "TXT_COLOR=0"
IF NOT DEFINED PAD_SIZE SET "PAD_SIZE=LARGE"
IF NOT DEFINED PAD_SEQ SET "PAD_SEQ=6666600000"
IF NOT DEFINED CHCP_OLD FOR /F "TOKENS=2 DELIMS=:" %%a IN ('CHCP') DO SET "CHCP_OLD=%%a"
FOR %%a in (1 2 3 4 5 6 7 8) DO (IF "%PAD_TYPE%"=="%%a" CHCP 65001 >NUL)
IF "%PAD_TYPE%"=="0" SET "PADX= "
IF "%PAD_TYPE%"=="1" SET "PADX=◌"
IF "%PAD_TYPE%"=="2" SET "PADX=○"
IF "%PAD_TYPE%"=="3" SET "PADX=●"
IF "%PAD_TYPE%"=="4" SET "PADX=□"
IF "%PAD_TYPE%"=="5" SET "PADX=■"
IF "%PAD_TYPE%"=="6" SET "PADX=░"
IF "%PAD_TYPE%"=="7" SET "PADX=▒"
IF "%PAD_TYPE%"=="8" SET "PADX=▓"
IF "%PAD_TYPE%"=="9" SET "PADX=~"
IF "%PAD_TYPE%"=="10" SET "PADX=="
IF "%PAD_TYPE%"=="11" SET "PADX=#"
CALL SET "#@=%%XLR%ACC_COLOR%%%"&&CALL SET "##=%%XLR%BTN_COLOR%%%"&&CALL SET "#$=%%XLR%TXT_COLOR%%%"&&IF "%PAD_TYPE%"=="0" ECHO.%#$%&&EXIT /B
SET "PAD_SEQX=%PAD_SEQ%"&&IF NOT "%PAD_SEQ%X"=="%PAD_SEQX%X" SET "XNTX=0"&&SET "XLRX="&&FOR /F "DELIMS=" %%G IN ('CMD.EXE /D /U /C ECHO.%PAD_SEQ%^| FIND /V ""') do (CALL SET "XLRX=%%G"&&CALL:COLOR_ASSIGN&&CALL SET /A XNTX+=1)
IF "%PAD_SIZE%"=="LARGE" SET "PAD_BLK=%PADX%%PADX%%PADX%%PADX%%PADX%%PADX%%PADX%%PADX%%PADX%%PADX%"
IF "%PAD_SIZE%"=="SMALL" SET "PAD_BLK=%#0%%PADX%%#1%%PADX%%#2%%PADX%%#3%%PADX%%#4%%PADX%%#5%%PADX%%#6%%PADX%%#7%%PADX%%#8%%PADX%%#9%%PADX%"
IF "%PAD_SIZE%"=="LARGE" ECHO.%#0%%PAD_BLK%%#1%%PAD_BLK%%#2%%PAD_BLK%%#3%%PAD_BLK%%#4%%PAD_BLK%%#5%%PAD_BLK%%#6%%PAD_BLK%%#$%
IF "%PAD_SIZE%"=="SMALL" ECHO.%PAD_BLK%%PAD_BLK%%PAD_BLK%%PAD_BLK%%PAD_BLK%%PAD_BLK%%PAD_BLK%%#$%
SET "#Z=%#$%"&&SET "#0=%#1%"&SET "#1=%#2%"&SET "#2=%#3%"&SET "#3=%#4%"&SET "#4=%#5%"&SET "#5=%#6%"&SET "#6=%#7%"&SET "#7=%#8%"&SET "#8=%#9%"&SET "#9=%#0%"&&SET "PAD_BLK="&&SET "PADX="&&SET "XLRX=%#$%"&&FOR %%a in (1 2 3 4 5 6 7 8) DO (IF "%PAD_TYPE%"=="%%a" CHCP %CHCP_OLD% >NUL)
EXIT /B
:COLOR_ASSIGN
IF DEFINED XNTX CALL SET "#%XNTX%=%%XLR%XLRX%%%"
EXIT /B
:BOXT1
SET "BOX=T1"&&GOTO:BOX_DISP
:BOXB1
SET "BOX=B1"&&GOTO:BOX_DISP
:BOXT2
SET "BOX=T2"&&GOTO:BOX_DISP
:BOXB2
SET "BOX=B2"&&GOTO:BOX_DISP
:BOX_DISP
IF "%PAD_BOX%"=="DISABLED" EXIT /B
IF NOT DEFINED CHCP_OLD FOR /F "TOKENS=2 DELIMS=:" %%a IN ('CHCP') DO SET "CHCP_OLD=%%a"
CHCP 65001 >NUL
IF "%BOX%"=="0" ECHO.%##%► ◄%#$%
IF "%BOX%"=="T1" ECHO.%##%╭────────────────────────────────────────────────────────────────────╮%#$%
IF "%BOX%"=="B1" ECHO.%##%╰────────────────────────────────────────────────────────────────────╯%#$%
IF "%BOX%"=="T2" ECHO.%##%┌────────────────────────────────────────────────────────────────────┐%#$%
IF "%BOX%"=="B2" ECHO.%##%└────────────────────────────────────────────────────────────────────┘%#$%
SET "BOX="&&CHCP %CHCP_OLD% >NUL
EXIT /B
:MENU_SELECT
SET "$TRUMP="&&SET "SELECT="&&SET /P "SELECT=$>>"
IF NOT DEFINED SELECT EXIT /B
SET "SELECT=%SELECT:"=%"
SET "SELECT=%SELECT:&=%"
SET "SELECT=%SELECT:>=%"
SET "SELECT=%SELECT:<=%"
SET "SELECT=%SELECT:|=%"
SET "SELECT=%SELECT:!=%"
FOR /F "TOKENS=1-2 DELIMS=<>&|!" %%a in ("%SELECT%") DO (SET "CAPS_SET=SELECT"&&SET "CAPS_VAR=%%a"&&CALL:CAPS_SET)
IF "%SELECT%"=="=" SET "SELECT="
CALL SET "$TRUMP=%%$ITEM%SELECT%%%"
EXIT /B
:PROMPT_SET
IF NOT DEFINED PROMPT_SET SET "PROMPT_SET=SELECT"
SET "%PROMPT_SET%="&&SET "PROMPT_VAR="&&SET /P "PROMPT_VAR=$>>"
IF NOT DEFINED PROMPT_VAR GOTO:PROMPT_SET_END
IF DEFINED NO_FILT GOTO:NO_FILT
IF NOT DEFINED NO_QUOTES SET "PROMPT_VAR=%PROMPT_VAR:"=%"
SET "PROMPT_VAR=%PROMPT_VAR:&=%"
SET "PROMPT_VAR=%PROMPT_VAR:>=%"
SET "PROMPT_VAR=%PROMPT_VAR:<=%"
SET "PROMPT_VAR=%PROMPT_VAR:|=%"
SET "PROMPT_VAR=%PROMPT_VAR:!=%"
FOR /F "TOKENS=1-2 DELIMS=<>&|!" %%a in ("%PROMPT_VAR%") DO (SET "PROMPT_VAR=%%a")
IF "%PROMPT_VAR%"=="=" SET "%PROMPT_SET%="&&GOTO:PROMPT_SET_END
:NO_FILT
SET "CAPS_SET=%PROMPT_SET%"&&SET "CAPS_VAR=%PROMPT_VAR%"
IF DEFINED PROMPT_ANY CALL SET "%CAPS_SET%=%CAPS_VAR%"
IF NOT DEFINED PROMPT_ANY CALL:CAPS_SET
:PROMPT_SET_END
SET "PROMPT_ANY="&&SET "PROMPT_SET="&&SET "PROMPT_VAR="&&SET "NO_FILT="&&SET "NO_QUOTES="
EXIT /B
:CAPS_SET
IF NOT DEFINED CASE SET "CASE=UPPER"
IF "%CASE%"=="LOWER" FOR %%G in (a b 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 (CALL SET "CAPS_VAR=%%CAPS_VAR:%%G=%%G%%")
IF "%CASE%"=="UPPER" FOR %%G in (A B 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 (CALL SET "CAPS_VAR=%%CAPS_VAR:%%G=%%G%%")
IF "%CAPS_VAR%"=="a=a" SET "CAPS_VAR="
IF "%CAPS_VAR%"=="A=A" SET "CAPS_VAR="
CALL SET "%CAPS_SET%=%CAPS_VAR%"&&SET "CAPS_SET="&&SET "CAPS_VAR="&&SET "CASE="
EXIT /B
:CHAR_CHK
FOR %%a in (CHAR_STR CHAR_CHK) DO (IF NOT DEFINED %%a EXIT /B)
SET "CHAR_FLG="&&FOR /F "DELIMS=" %%$ in ('CMD.EXE /D /U /C ECHO.%CHAR_STR%^| FIND /V ""') do (IF "%%$"=="%CHAR_CHK%" SET "ERROR=1"&&SET "CHAR_FLG=1")
EXIT /B
:CHECK
SET "ERROR="&&IF NOT DEFINED CHECK_VAR SET "ERROR=1"
IF "%CHECK%"=="CUST" SET "CHECK_FLT=%CHECK_FLT%"
IF "%CHECK%"=="NUM" SET "CHECK_FLT=0 1 2 3 4 5 6 7 8 9"
IF "%CHECK%"=="LTR" SET "CHECK_FLT=A B C D E F G H I J K L M N O P Q R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z"
IF "%CHECK%"=="ALPHA" SET "CHECK_FLT=0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z"
IF NOT DEFINED ERROR FOR /F "DELIMS=" %%$ in ('CMD.EXE /D /U /C ECHO.%CHECK_VAR%^| FIND /V ""') do (
SET "PASS="&&FOR %%a in (%CHECK_FLT%) DO (IF "%%a"=="%%$" SET "PASS=1")
IF NOT DEFINED PASS SET "ERROR=1"
IF NOT DEFINED SPACE IF "%%$"==" " SET "ERROR=1")
IF DEFINED ERROR ECHO. %XLR4%ERROR:%#$% input [ %XLR4%%CHECK_VAR%%#$% ] is invalid
SET "CHECK="&&SET "CHECK_VAR="&&SET "CHECK_FLT="&&SET "SPACE="
EXIT /B
:FREE_CALC
SET "FREE="&&FOR /F "TOKENS=1-5 DELIMS= " %%a IN ('DIR "%PROG_SOURCE%\*."') DO (IF "%%d %%e"=="bytes free" SET "FREE_Z=%%c")
IF NOT DEFINED FREE_Z SET "FREE=ERROR"&&EXIT /B
SET "FREE_Z=%FREE_Z:,=%"
FOR /F "DELIMS=" %%G in ('CMD.EXE /D /U /C ECHO.%FREE_Z%^| FIND /V ""') do (SET "FREE_X=%%G"&&SET /A "FREE_XNT+=1"&&CALL:FREE_XNT)
IF %FREE_XNT% LSS 10 SET "FREE=0"
IF "%FREE_XNT%"=="10" SET "FREE=%FREE1%"
IF "%FREE_XNT%"=="11" SET "FREE=%FREE1%%FREE2%"
IF "%FREE_XNT%"=="12" SET "FREE=%FREE1%%FREE2%%FREE3%"
IF "%FREE_XNT%"=="13" SET "FREE=%FREE1%%FREE2%%FREE3%%FREE4%"
IF "%FREE_XNT%"=="14" SET "FREE=%FREE1%%FREE2%%FREE3%%FREE4%%FREE5%"
FOR %%a in (0 1 2 3 4 5 _XNT _X _Z) DO (SET "FREE%%a=")
EXIT /B
:FREE_XNT
IF %FREE_XNT% GTR 5 EXIT /B
SET "FREE%FREE_XNT%=%FREE_X%"
EXIT /B
:PAD_PREV
ECHO. Press (%##%Enter%#$%) to return to previous menu
EXIT /B
:PAUSED
SET /P "PAUSED=. Press (%##%Enter%#$%) to continue..."
EXIT /B
:CLEAN
IF NOT EXIST "$DSK" EXIT /B
IF EXIST "$DSK" DEL /Q /F "$DSK">NUL
EXIT /B
:VER_GET
IF NOT DEFINED VER_SET SET "VER_SET=VER_CUR"
IF EXIST "%VER_GET%" SET /P VER_CHK=<"%VER_GET%"
FOR /F "TOKENS=1-9 DELIMS= " %%A IN ("%VER_CHK%") DO (SET "%VER_SET%=%%H")
SET "VER_CHK="&&SET "VER_GET="&&SET "VER_SET="
EXIT /B
:RECOVERY_LOCK
SET "LOCKOUT="&&ECHO. Enter password
SET "PROMPT_SET=RECOVERY_PROMPT"&&SET "PROMPT_ANY=1"&&CALL:PROMPT_SET
SET /P RECOVERY_LOCK=<"%PROG_FOLDER%\RECOVERY_LOCK"
IF NOT "%RECOVERY_PROMPT%"=="%RECOVERY_LOCK%" SET "LOCKOUT=1"
SET "RECOVERY_PROMPT="&&SET "RECOVERY_LOCK="
EXIT /B
:SETS_LIST
SET SETS_LIST=PAD_BOX PAD_TYPE PAD_SIZE PAD_SEQ TXT_COLOR ACC_COLOR BTN_COLOR WIM_XLVL HOST_HIDE ADDFILE_1 ADDFILE_2 ADDFILE_3 ADDFILE_4 ADDFILE_5 BOOT_TIMEOUT VHDX_SLOT0 VHDX_SLOT1 VHDX_SLOT2 VHDX_SLOT3 VHDX_SLOT4 VHDX_SLOT5 VHDX_SLOT6 VHDX_SLOT7 VHDX_SLOT8 VHDX_SLOT9
EXIT /B
:SETS_LOAD
IF EXIST "settings.ini" FOR /F "eol=- TOKENS=1-2 DELIMS==" %%a in (settings.ini) DO (IF NOT "%%a"==" " SET "%%a=%%b")
EXIT /B
:SETS_CLEAR
CALL:SETS_LIST
FOR %%a in (%SETS_LIST%) DO (SET %%a=)
SET "SETS_LIST="&&EXIT /B
:SETS_HANDLER
IF NOT EXIST "%PROG_SOURCE%" SET "PROG_SOURCE=%PROG_FOLDER%"
CD /D "%PROG_FOLDER%"&&IF EXIST "settings.ini" IF NOT DEFINED $ETS SET "$ETS=1"&&CALL:SETS_LOAD
CALL:SETS_LIST&&ECHO.deploid Settings>"settings.ini"
FOR %%a in (%SETS_LIST%) DO (CALL ECHO.%%a=%%%%a%%>>"settings.ini")
SET "SETS_LIST="&&IF "%PROG_MODE%"=="RAMDISK" IF "%PROG_SOURCE%"=="X:\$" SET "HOST_GET=1"
IF "%PROG_MODE%"=="RAMDISK" IF NOT "%DISK_TARGET%"=="%HOST_TARGET%" SET "HOST_GET=1"
IF DEFINED HOST_GET SET "HOST_GET="&&CALL:HOST_AUTO
IF "%PROG_MODE%"=="RAMDISK" IF EXIST "Z:\%HOST_FOLDERX%" COPY /Y "settings.ini" "Z:\%HOST_FOLDERX%">NUL
:SETS_MAIN
IF NOT DEFINED WIM_XLVL SET "WIM_XLVL=FAST"
IF NOT DEFINED PAD_BOX SET "PAD_BOX=ENABLED"
IF NOT DEFINED PAD_SEQ SET "PAD_SEQ=6666600000"
IF NOT DEFINED HOST_FOLDER SET "HOST_FOLDER=deploid"
IF NOT DEFINED HOST_HIDE SET "HOST_HIDE=DISABLED"
FOR %%a in (CACHE IMAGE PACK LIST BOOT) DO (SET "%%a_FOLDER=%PROG_SOURCE%")
IF NOT DEFINED XLR0 SET "XLR0=[97m"&&SET "XLR1=[31m"&&SET "XLR2=[91m"&&SET "XLR3=[33m"&&SET "XLR4=[93m"&&SET "XLR5=[92m"&&SET "XLR6=[96m"&&SET "XLR7=[94m"&&SET "XLR8=[34m"&&SET "XLR9=[95m"&&CALL:PAD_LINE>NUL 2>&1
FOR %%a in (PE_WALLPAPER VHDX_SLOTX SELECTX SELECTY SELECTZ APPLYDIR CAPTUREDIR IMAGEINDEX $VHDX ERROR LIVE_APPLY $HALT $HALTX VDISK VDISK_LTR) DO (SET "%%a=")
IF "%PROG_MODE%"=="RAMDISK" FOR %%a in (VHDX_SLOT0 VHDX_SLOT1 VHDX_SLOT2 VHDX_SLOT3 VHDX_SLOT4 VHDX_SLOT5 VHDX_SLOT6 VHDX_SLOT7 VHDX_SLOT8 VHDX_SLOT9) DO (SET "OBJ_FLD=%PROG_SOURCE%"&&CALL SET "OBJ_CHK=%%a"&&CALL:OBJ_CLEAR)
FOR %%a in (1 2 3 4 5) DO (SET "OBJ_FLD=%PROG_SOURCE%"&&CALL SET "OBJ_CHK=ADDFILE_%%a"&&CALL:OBJ_CLEAR)
FOR %%a in (VHDX_SLOTX VHDX_SLOT0 VHDX_SLOT1 VHDX_SLOT2 VHDX_SLOT3 VHDX_SLOT4 VHDX_SLOT5 VHDX_SLOT6 VHDX_SLOT7 VHDX_SLOT8 VHDX_SLOT9) DO (IF NOT DEFINED %%a SET "%%a=SELECT")
SET "OBJ_FLD="&&SET "OBJ_CHK="&&SET "OBJ_CHKX="&&IF "%WIM_SOURCE%"=="SELECT" SET "WIM_INDEX=1"
EXIT /B
:OBJ_CLEAR
CALL SET "OBJ_CHKX=%%%OBJ_CHK%%%"
IF NOT EXIST "%OBJ_FLD%\%OBJ_CHKX%" CALL SET "%OBJ_CHK%=SELECT"
EXIT /B
:FILE_PICK
IF NOT DEFINED PICK GOTO:PICK_ERROR
IF NOT DEFINED NOCLS CLS
IF NOT DEFINED NOPAD CALL:PAD_LINE
CALL:BOXT1&&SET "NLIST=%PICK%"&&CALL:FILE_LIST&&CALL:BOXB1&&IF NOT DEFINED NOPAD CALL:PAD_LINE
FOR %%a in (ERROR SELECT $LIST_NAME $MAKE $PICK $TRUMP $HEAD $PICK_PATH $PICK_BODY $PICK_EXT FILE_NAME NOCLS NOPAD) DO (SET "%%a=")
CALL:PAD_PREV&&CALL:MENU_SELECT
IF "%SELECT%"=="." GOTO:PICK_ERROR
IF "%SELECT%" GTR "9999999" SET "ERROR=1"
IF "%SELECT%" LSS "1" SET "ERROR=1"
IF NOT DEFINED $TRUMP SET "ERROR=1"
IF NOT DEFINED $FOLD_X SET "ERROR=1"
IF DEFINED ERROR GOTO:PICK_ERROR
IF EXIST "%$FOLD_X%\%$TRUMP%" SET "$PICK=%$FOLD_X%\%$TRUMP%"
:PICK_ERROR
IF NOT DEFINED ERROR FOR %%G in ("%$PICK%") DO (SET "$PICK_PATH=%%~dG%%~pG"&&SET "$PICK_BODY=%%~nG"&&SET "$PICK_EXT=%%~xG")
IF NOT DEFINED ERROR FOR %%G in (A B 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 (CALL SET "$PICK_PATH=%%$PICK_PATH:%%G=%%G%%"&&CALL SET "$PICK_BODY=%%$PICK_BODY:%%G=%%G%%"&&CALL SET "$PICK_EXT=%%$PICK_EXT:%%G=%%G%%")
SET "PICK="&&IF DEFINED ERROR SET "$PICK="
EXIT /B
:FILE_LIST
SET "EMPTY_X=1"&&SET "$FOLD_X="&&SET "$FILT_X="&&SET "$XNT="&&FOR %%a in (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) DO (IF DEFINED $ITEM%%a SET "$ITEM%%a=")
IF NOT DEFINED BLIST IF NOT DEFINED NLIST GOTO:FILE_ERROR
FOR %%a in (BLIST NLIST) DO (IF DEFINED %%a CALL SET "EXT=%%%%a%%")
FOR %%a in (0 1 2 3 4 5 6 7 8 9) DO (IF DEFINED MENUT%%a CALL ECHO.%%MENUT%%a%%&&SET "MENUT%%a=")
FOR %%a in (ISO VHDX WIM) DO (IF "%EXT%"=="%%a" SET "$FOLD_X=%IMAGE_FOLDER%"&&SET "$FILT_X=*.%EXT%"&&CALL:FILE_LIST_FOLD)
IF "%EXT%"=="CUST" FOR %%X in (0 1 2 3 4 5 6 7 8 9) DO (IF DEFINED $FOLD%%X IF DEFINED $FILT%%X CALL SET "$FOLD_X=%%$FOLD%%X%%"&&CALL SET "$FILT_X=%%$FILT%%X%%"&&SET "$FOLD%%X="&&SET "$FILT%%X="&&CALL:FILE_LIST_FOLD)
IF DEFINED EMPTY_X ECHO. EMPTY..
FOR %%a in (0 1 2 3 4 5 6 7 8 9) DO (IF DEFINED MENUB%%a CALL ECHO.%%MENUB%%a%%&&SET "MENUB%%a=")
:FILE_ERROR
FOR %%a in ($FILT_X EMPTY_X EXT BLIST NLIST $XNT) DO (SET "%%a=")
EXIT /B
:FILE_LIST_FOLD
FOR /F "TOKENS=1-9 DELIMS= " %%a in ("%$FILT_X%") DO (IF NOT "%%a"=="" SET "$FILT_X=%%a"&&CALL:FILE_LIST_FILT&&IF NOT "%%b"=="" SET "$FILT_X=%%b"&&CALL:FILE_LIST_FILT&&IF NOT "%%c"=="" SET "$FILT_X=%%c"&&CALL:FILE_LIST_FILT&&IF NOT "%%d"=="" SET "$FILT_X=%%d"&&CALL:FILE_LIST_FILT&&IF NOT "%%e"=="" SET "$FILT_X=%%e"&&CALL:FILE_LIST_FILT&&IF NOT "%%f"=="" SET "$FILT_X=%%f"&&CALL:FILE_LIST_FILT&&IF NOT "%%g"=="" SET "$FILT_X=%%g"&&CALL:FILE_LIST_FILT&&IF NOT "%%h"=="" SET "$FILT_X=%%h"&&CALL:FILE_LIST_FILT)
EXIT /B
:FILE_LIST_FILT
IF EXIST "%$FOLD_X%\%$FILT_X%" SET "EMPTY_X="&&FOR /F "TOKENS=*" %%a in ('DIR /A: /B /O:GN "%$FOLD_X%\%$FILT_X%"') DO (CALL SET /A "$XNT+=1"&&CALL SET "$CLM$=%%a"&&CALL:FILE_LISTX)
EXIT /B
:FILE_LISTX
CALL SET "$ITEM%$XNT%=%$CLM$%"
IF EXIST "%$FOLD_X%\%$CLM$%\*" (SET "LIST_CLR1=%#@%"&&SET "LIST_CLR2=%#$%") ELSE (SET "LIST_CLR1="&&SET "LIST_CLR2=")
IF DEFINED NLIST ECHO. ( %##%%$XNT%%#$% ) %LIST_CLR1%%$CLM$%%LIST_CLR2%
IF DEFINED BLIST ECHO. %LIST_CLR1%%$CLM$%%LIST_CLR2%
EXIT /B
::#########################################################################
:SETTINGS_MENU
::#########################################################################
CLS&&CALL:SETS_HANDLER&&CALL:PAD_LINE&&CALL:BOXT1&&ECHO. Settings Configuration&&ECHO.
ECHO. (%##%-%#$%) Color Shift (%##%+%#$%)&&ECHO. (%##%1%#$%) Pad Type %#@%PAD %PAD_TYPE%%#$%&&ECHO. (%##%2%#$%) Pad Size %#@%%PAD_SIZE%%#$%&&ECHO. (%##%3%#$%) Pad Sequence %#@%%PAD_SEQ%%#$%&&CALL ECHO. (%##%4%#$%) Text Color %#@%COLOR %%XLR%TXT_COLOR%%%%TXT_COLOR%%#$%&&CALL ECHO. (%##%5%#$%) Accent Color %#@%COLOR %%XLR%ACC_COLOR%%%%ACC_COLOR%%#$%&&CALL ECHO. (%##%6%#$%) Button Color %#@%COLOR %%XLR%BTN_COLOR%%%%BTN_COLOR%%#$%&&CALL ECHO. (%##%7%#$%) Pad Box %#@%%PAD_BOX%%#$%&&CALL ECHO. (%##%8%#$%) Compression %#@%%WIM_XLVL%%#$%&&ECHO. (%##%9%#$%) Add File&&IF "%PROG_MODE%"=="RAMDISK" ECHO. (%##%10%#$%) Update&&ECHO. (%##%11%#$%) Host Hide %#@%%HOST_HIDE%%#$%
ECHO. (%##%@%#$%) Clear Settings&&ECHO.&&CALL:BOXB1&&CALL:PAD_LINE&&CALL:PAD_PREV&&CALL:MENU_SELECT
IF NOT DEFINED SELECT IF "%PROG_MODE%"=="RAMDISK" GOTO:MAIN_MENU
IF NOT DEFINED SELECT IF "%PROG_MODE%"=="PORTABLE" GOTO:BASIC_CREATOR
IF "%SELECT%"=="@" CALL:SETS_CLEAR&SET "SELECT="
IF "%SELECT%"=="+" CALL:COLOR_SHIFT_TXT&SET "SELECT="
IF "%SELECT%"=="-" CALL:COLOR_SHIFT_PAD&SET "SELECT="
IF "%SELECT%"=="1" CALL:PAD_TYPE&SET "SELECT="
IF "%SELECT%"=="2" IF "%PAD_SIZE%"=="LARGE" SET "PAD_SIZE=SMALL"&SET "SELECT="
IF "%SELECT%"=="2" IF "%PAD_SIZE%"=="SMALL" SET "PAD_SIZE=LARGE"&SET "SELECT="
IF "%SELECT%"=="3" CALL:PAD_LINE&&CALL:BOXT1&&ECHO.&&ECHO. Enter 10 digit color sequence seed&&ECHO.&&ECHO. [ %XLR0%0%XLR1%1%XLR2%2%XLR3%3%XLR4%4%XLR5%5%XLR6%6%XLR7%7%XLR8%8%XLR9%9%#$% ] [ %XLR1%11%XLR2%22%XLR3%33%XLR4%44%XLR5%55%#$% ]&&ECHO.&&CALL:BOXB1&&CALL:PAD_LINE&&SET "PROMPT_SET=COLOR_XXX"&&CALL:PROMPT_SET
IF "%SELECT%"=="3" IF "%COLOR_XXX%"=="-" SET "PAD_SEQ=6666600000"&SET "SELECT="
IF "%SELECT%"=="3" SET "XNTX="&&FOR /F "DELIMS=" %%G IN ('CMD.EXE /D /U /C ECHO.%COLOR_XXX%^| FIND /V ""') do (CALL SET /A XNTX+=1)
IF "%SELECT%"=="3" IF "%XNTX%"=="10" SET "PAD_SEQ=%COLOR_XXX%"&&SET "COLOR_XXX="&SET "SELECT="
IF "%SELECT%"=="4" SET "COLOR_TMP=TXT_COLOR"&&CALL:COLOR_CHOICE&SET "SELECT="
IF "%SELECT%"=="5" SET "COLOR_TMP=ACC_COLOR"&&CALL:COLOR_CHOICE&SET "SELECT="
IF "%SELECT%"=="6" SET "COLOR_TMP=BTN_COLOR"&&CALL:COLOR_CHOICE&SET "SELECT="
IF "%SELECT%"=="7" IF "%PAD_BOX%"=="DISABLED" SET "PAD_BOX=ENABLED"&SET "SELECT="
IF "%SELECT%"=="7" IF "%PAD_BOX%"=="ENABLED" SET "PAD_BOX=DISABLED"&SET "SELECT="
IF "%SELECT%"=="8" CALL:IMAGEPROC_XLVL&SET "SELECT="
IF "%SELECT%"=="9" CALL:ADDFILE_MENU&SET "SELECT="
IF "%SELECT%"=="10" IF "%PROG_MODE%"=="RAMDISK" GOTO:UPDATE_RECOVERY
IF "%SELECT%"=="11" IF "%PROG_MODE%"=="RAMDISK" IF "%HOST_HIDE%"=="DISABLED" SET "HOST_HIDE=ENABLED"&&CALL:PAD_LINE&&CALL:BOXT1&&ECHO.&&ECHO.VHDX host partition will be hidden upon exit. Boot into recovery to revert.&&ECHO.&&CALL:BOXB1&&CALL:PAD_LINE&&CALL:PAUSED&SET "SELECT="
IF "%SELECT%"=="11" IF "%PROG_MODE%"=="RAMDISK" IF "%HOST_HIDE%"=="ENABLED" SET "HOST_HIDE=DISABLED"&&SET "SELECT="
GOTO:SETTINGS_MENU
:ADDFILE_MENU
CLS&&CALL:SETS_HANDLER&&CALL:CLEAN&&CALL:PAD_LINE&&CALL:BOXT1&&ECHO. Add File&&ECHO.
FOR %%G in (1 2 3 4 5) DO (CALL ECHO. File ^(%##%%%G%#$%^) %#@%%%ADDFILE_%%G%%%#$%)
ECHO.&&CALL:BOXB1&&CALL:PAD_LINE&&CALL:PAD_PREV&&CALL:MENU_SELECT
IF NOT DEFINED SELECT EXIT /B
SET "ACTION_X="&&FOR %%G in (1 2 3 4 5) DO (IF "%SELECT%"=="%%G" SET "ACTION_X=%SELECT%"&&CLS&&SET "MENUT0= Add File"&&SET "MENUT1= "&&SET "MENUT2= %#@%AVAILABLE FILEs:%#$%"&&SET "MENUT3= "&&SET "MENUB0= "&&SET "PICK=CUST"&&SET "$FOLD0=%PROG_SOURCE%"&&SET "$FILT0=*.*"&&CALL:FILE_PICK)
IF DEFINED ACTION_X IF DEFINED $PICK IF EXIST "%$PICK%" IF NOT EXIST "%$PICK%\*" SET "ADDFILE_%ACTION_X%=%$TRUMP%"
IF DEFINED ACTION_X IF NOT DEFINED $PICK SET "ADDFILE_%ACTION_X%=SELECT"
GOTO:ADDFILE_MENU
:PAD_TYPE
IF NOT DEFINED CHCP_OLD FOR /F "TOKENS=2 DELIMS=:" %%a IN ('CHCP') DO SET "CHCP_OLD=%%a"
CHCP 65001 >NUL
CLS&&CALL:PAD_LINE&&CALL:BOXT1&&ECHO.&&ECHO. Choose a pad type&&ECHO.&&ECHO. (%##%0%#$%)None (%##%1%#$%)◌ (%##%2%#$%)○ (%##%3%#$%)● (%##%4%#$%)□ (%##%5%#$%)■ (%##%6%#$%)░ (%##%7%#$%)▒ (%##%8%#$%)▓ (%##%9%#$%)~ (%##%10%#$%)= (%##%11%#$%)#&&CHCP %CHCP_OLD% >NUL
ECHO.&&CALL:BOXB1&&CALL:PAD_LINE&&CALL:PAD_PREV&&SET "PROMPT_SET=PAD_TYPE"&&CALL:PROMPT_SET
SET "PASS="&&FOR %%a in (0 1 2 3 4 5 6 7 8 9 10 11) DO (IF "%PAD_TYPE%"=="%%a" SET "PASS=1")
IF NOT "%PASS%"=="1" SET "PAD_TYPE=1"
EXIT /B
:COLOR_CHOICE
CALL:PAD_LINE&&CALL:BOXT1&&ECHO.&&ECHO. Choose a color&&ECHO.&&ECHO. [ %XLR0% 0 %XLR1% 1 %XLR2% 2 %XLR3% 3 %XLR4% 4 %XLR5% 5 %XLR6% 6 %XLR7% 7 %XLR8% 8 %XLR9% 9 %#$% ]&&ECHO.&&CALL:BOXB1&&CALL:PAD_LINE&&CALL:PAD_PREV&&SET "PROMPT_SET=COLOR_123"&&CALL:PROMPT_SET
SET "PASS="&&FOR %%a in (0 1 2 3 4 5 6 7 8 9) DO (IF "%COLOR_123%"=="%%a" SET "PASS=1")
IF "%PASS%"=="1" SET "%COLOR_TMP%=%COLOR_123%"
SET "COLOR_TMP="&&SET "COLOR_123="&&EXIT /B
:COLOR_SHIFT_PAD
FOR /F "DELIMS=" %%G in ('CMD.EXE /D /U /C ECHO.%PAD_SEQ%^| FIND /V ""') do (SET "XXX_XXX=%%G"&&SET /A "PAD_XNT+=1"&&CALL:PAD_XNT)
SET "PAD_SEQ=%PAD_SHIFT%"&&FOR %%a in (PAD_SHIFT PAD_XNT XXX_XXX) DO (SET "%%a=")
EXIT /B
:COLOR_SHIFT_TXT
FOR %%a in (TXT_COLOR ACC_COLOR BTN_COLOR) DO (SET /A "%%a+=1")
IF "%TXT_COLOR%"=="10" SET "TXT_COLOR=0"
IF "%ACC_COLOR%"=="10" SET "ACC_COLOR=0"
IF "%BTN_COLOR%"=="10" SET "BTN_COLOR=0"
EXIT /B
:PAD_XNT
IF %PAD_XNT% GTR 10 EXIT /B
SET /A "XXX_XXX+=1"&&IF "%XXX_XXX%"=="9" SET "XXX_XXX=0"
SET "PAD_SHIFT=%PAD_SHIFT%%XXX_XXX%"
EXIT /B
:UPDATE_RECOVERY
SET "PROG_NAME=deploid"&&CLS&&CALL:SETS_HANDLER&&CALL:PAD_LINE&&CALL:BOXT1&&ECHO. Recovery Update&&ECHO.&&ECHO. (%##%1%#$%) Program (%##%*%#$%) Test&&ECHO. (%##%2%#$%) Recovery Wallpaper&&ECHO. (%##%3%#$%) Recovery Password&&ECHO. (%##%4%#$%) Boot Media&&ECHO. (%##%5%#$%) Host Folder&&ECHO. (%##%6%#$%) EFI Files&&ECHO.&&CALL:BOXB1&&CALL:PAD_LINE&&CALL:PAD_PREV&&CALL:MENU_SELECT
IF DEFINED HOST_ERROR GOTO:MAIN_MENU
IF NOT DEFINED SELECT GOTO:SETTINGS_MENU
IF NOT "%SELECT%"=="*" IF NOT "%SELECT%"=="1" IF NOT "%SELECT%"=="2" IF NOT "%SELECT%"=="3" IF NOT "%SELECT%"=="4" IF NOT "%SELECT%"=="5" IF NOT "%SELECT%"=="6" GOTO:UPDATE_RECOVERY
IF "%SELECT%"=="*" IF EXIST "%PROG_SOURCE%\%PROG_NAME%.cmd" SET "VER_GET=%PROG_SOURCE%\%PROG_NAME%.cmd"&&CALL:VER_GET&© /Y "%PROG_SOURCE%\%PROG_NAME%.cmd" "%PROG_FOLDER%"&&GOTO:MAIN_MENU
FOR %%a in (0 1 2 3 ERROR) DO (IF "%FREE%"=="%%a" CALL:PAD_LINE&&CALL:BOXT1&&ECHO.&&ECHO. Not enough free space. Clear some space and try again.&&ECHO.&&CALL:BOXB1&&CALL:PAD_LINE&&SET "ERROR=1"&&CALL:PAUSED&GOTO:UPDATE_END)
IF "%SELECT%"=="1" SET "UPDATE_TYPE=PROG"
IF "%SELECT%"=="2" SET "UPDATE_TYPE=WALL"
IF "%SELECT%"=="3" SET "UPDATE_TYPE=PASS"
IF "%SELECT%"=="4" SET "UPDATE_TYPE=BOOT"
IF "%SELECT%"=="5" SET "UPDATE_TYPE=HOST"
IF "%SELECT%"=="6" SET "UPDATE_TYPE=EFI"
IF "%UPDATE_TYPE%"=="EFI" IF NOT EXIST "%BOOT_FOLDER%\boot.sdi" IF NOT EXIST "%BOOT_FOLDER%\bootmgfw.efi" ECHO. %XLR4%ERROR:%#$% Files boot.sdi and bootmgfw.efi are not located in folder. Abort.&&SET "ERROR=1"&&CALL:PAUSED&GOTO:UPDATE_END
IF "%UPDATE_TYPE%"=="BOOT" IF NOT EXIST "%BOOT_FOLDER%\boot.sav" ECHO. %XLR4%ERROR:%#$% File boot.sav is not located in folder. Abort.&&SET "ERROR=1"&&CALL:PAUSED&GOTO:UPDATE_END
IF "%UPDATE_TYPE%"=="PROG" IF NOT EXIST "%PROG_SOURCE%\%PROG_NAME%.cmd" ECHO. %XLR4%ERROR:%#$% File %PROG_NAME%.cmd is not located in folder. Abort.&&SET "ERROR=1"&&CALL:PAUSED&GOTO:UPDATE_END
IF "%UPDATE_TYPE%"=="PROG" SET "VER_GET=%PROG_SOURCE%\%PROG_NAME%.cmd"&&SET "VER_SET=VER_X"&&CALL:VER_GET
IF "%UPDATE_TYPE%"=="PROG" SET "VER_GET=%PROG_FOLDER%\%PROG_NAME%.cmd"&&SET "VER_SET=VER_Y"&&CALL:VER_GET
IF "%UPDATE_TYPE%"=="PASS" CALL:PAD_LINE&&CALL:BOXT1&&ECHO.&&ECHO. %XLR4%Important:%#$% Do not use any of these symbols [%XLR2% ^< ^> %% ^^! ^& ^^^^ %#$%].&&ECHO.&&ECHO. Enter new recovery password or leave blank to remove.&&ECHO.&&CALL:BOXB1&&CALL:PAD_LINE&&SET "PROMPT_SET=RECOVERY_LOCK"&&SET "PROMPT_ANY=1"&&CALL:PROMPT_SET
IF "%UPDATE_TYPE%"=="WALL" CALL:PE_WALLPAPER
IF "%UPDATE_TYPE%"=="WALL" IF NOT DEFINED $PICK SET "ERROR=1"&&GOTO:UPDATE_END
IF "%UPDATE_TYPE%"=="HOST" CALL:HOST_FOLDER
IF "%UPDATE_TYPE%"=="HOST" IF DEFINED ERROR GOTO:UPDATE_END
IF "%UPDATE_TYPE%"=="BOOT" MOVE /Y "%BOOT_FOLDER%\boot.sav" "%BOOT_FOLDER%\$BOOT.wim">NUL
IF "%UPDATE_TYPE%"=="BOOT" FOR /F "TOKENS=1-9 SKIP=4 DELIMS=: " %%a in ('DISM /ENGLISH /GET-IMAGEINFO /IMAGEFILE:%BOOT_FOLDER%\$BOOT.wim /INDEX:1 2^>NUL') DO (IF "%%a"=="Version" SET "VER_X=%%b"
IF "%%a %%b"=="ServicePack Build" SET "VER_Z=%%c")
IF "%UPDATE_TYPE%"=="BOOT" MOVE /Y "%BOOT_FOLDER%\$BOOT.wim" "%BOOT_FOLDER%\boot.sav">NUL
IF "%UPDATE_TYPE%"=="BOOT" SET "VER_X=%VER_X%.%VER_Z%"&&SET "VER_Y="&&FOR /F "TOKENS=1-9 DELIMS=: " %%a in ('DISM /ENGLISH /ONLINE /GET-CURRENTEDITION 2^>NUL') DO (IF "%%a %%b"=="Image Version" SET "VER_Y=%%c")
CALL:PAD_LINE&&CALL:BOXT1&&ECHO.
IF "%UPDATE_TYPE%"=="EFI" ECHO. This will replace the current EFI boot files.
IF "%UPDATE_TYPE%"=="BOOT" ECHO. This will replace %#@%v%VER_Y%%#$% with %#@%v%VER_X%%#$%
IF "%UPDATE_TYPE%"=="PROG" ECHO. This will replace %#@%v%VER_Y%%#$% with %#@%v%VER_X%%#$%.
IF "%UPDATE_TYPE%"=="PASS" IF DEFINED RECOVERY_LOCK ECHO. Recovery password will be changed to %#@%%RECOVERY_LOCK%%#$%.
IF "%UPDATE_TYPE%"=="PASS" IF NOT DEFINED RECOVERY_LOCK ECHO. Recovery password will be cleared.
IF "%UPDATE_TYPE%"=="WALL" ECHO. This will replace the recovery background.
IF "%UPDATE_TYPE%"=="HOST" ECHO. Host folder will be changed to %#@%%HOST_FOLDER%%#$%.&&ECHO. %XLR4%NOTE:%#$% The boot menu will need to be configured next boot.
ECHO.&&CALL:BOXB1&&CALL:CONFIRM
IF NOT "%CONFIRM%"=="X" SET "ERROR=1"&&GOTO:UPDATE_END
SET "REBOOT_MAN=1"&&CLS&&CALL:BOXT2&&ECHO. %XLR4%Recovery update has been initiated.%#$%&&ECHO. %XLR2%Caution:%#$% Interrupting this process can render the disk unbootable.&&ECHO.
IF "%UPDATE_TYPE%"=="HOST" IF EXIST "Z:\%HOST_FOLDER%" ECHO. %XLR2%ERROR:%#$% HOST FOLDER ALREADY EXISTS&&SET "ERROR=1"&&GOTO:UPDATE_END
IF "%UPDATE_TYPE%"=="HOST" REN "Z:\%HOST_FOLDERX%" "%HOST_FOLDER%">NUL 2>&1
IF "%UPDATE_TYPE%"=="HOST" IF NOT EXIST "Z:\%HOST_FOLDER%" ECHO. %XLR2%ERROR:%#$% HOST FOLDER IN USE&&SET "ERROR=1"&&GOTO:UPDATE_END
IF "%UPDATE_TYPE%"=="HOST" REN "Z:\%HOST_FOLDER%" "%HOST_FOLDERX%">NUL 2>&1
CALL:EFI_MOUNT
IF DEFINED ERROR GOTO:UPDATE_END
IF "%UPDATE_TYPE%"=="EFI" IF EXIST "%BOOT_FOLDER%\boot.sdi" ECHO. Using boot.sdi located in folder, for efi image boot support.&© /Y "%BOOT_FOLDER%\boot.sdi" "%EFI_LETTER%:\Boot">NUL
IF "%UPDATE_TYPE%"=="EFI" IF EXIST "%BOOT_FOLDER%\bootmgfw.efi" ECHO. Using bootmgfw.efi located in folder, for the efi bootloader.&© /Y "%BOOT_FOLDER%\bootmgfw.efi" "%EFI_LETTER%:\EFI\Boot\bootx64.efi">NUL
IF "%UPDATE_TYPE%"=="EFI" FOR %%a in (boot.sdi bootmgfw.efi) DO (IF NOT EXIST "%BOOT_FOLDER%\%%a" ECHO. File %%a is not located in folder, skipping.)
IF "%UPDATE_TYPE%"=="EFI" ECHO. Unmounting EFI...&&CALL:EFI_UNMOUNT&GOTO:UPDATE_END
CALL:VTEMP_CREATE
IF DEFINED ERROR CALL:VTEMP_DELETE&CALL:EFI_UNMOUNT&GOTO:UPDATE_END
ECHO. Extracting boot-media...
IF "%UPDATE_TYPE%"=="BOOT" MOVE /Y "%BOOT_FOLDER%\boot.sav" "%BOOT_FOLDER%\$BOOT.wim">NUL
IF "%UPDATE_TYPE%"=="BOOT" SET "INDEX_WORD=Setup"&&SET "IMAGEFILE=%BOOT_FOLDER%\$BOOT.wim"&&CALL:FIND_INDEX
IF "%UPDATE_TYPE%"=="BOOT" SET "IMAGEFILE=%BOOT_FOLDER%\$BOOT.wim"&&CALL:APPLY_IMAGE
IF "%UPDATE_TYPE%"=="BOOT" MOVE /Y "%BOOT_FOLDER%\$BOOT.wim" "%BOOT_FOLDER%\boot.sav">NUL
IF NOT "%UPDATE_TYPE%"=="BOOT" SET "IMAGEFILE=%EFI_LETTER%:\$.WIM"&&CALL:APPLY_IMAGE
IF NOT EXIST "%APPLYDIR%\Windows" ECHO. %XLR2%ERROR:%#$% BOOT MEDIA&&SET "ERROR=1"&&CALL:VTEMP_DELETE&CALL:EFI_UNMOUNT&GOTO:UPDATE_END
IF "%UPDATE_TYPE%"=="BOOT" MD "%APPLYDIR%\$">NUL 2>&1
IF "%UPDATE_TYPE%"=="BOOT" COPY /Y "%PROG_FOLDER%\%PROG_NAME%.cmd" "%APPLYDIR%\$">NUL 2>&1
IF "%UPDATE_TYPE%"=="BOOT" COPY /Y "%PROG_FOLDER%\HOST_TARGET" "%APPLYDIR%\$">NUL 2>&1
IF "%UPDATE_TYPE%"=="BOOT" COPY /Y "%PROG_FOLDER%\HOST_FOLDER" "%APPLYDIR%\$">NUL 2>&1
IF "%UPDATE_TYPE%"=="BOOT" COPY /Y "%WINDIR%\System32\setup.bmp" "%APPLYDIR%\Windows\System32">NUL 2>&1
IF "%UPDATE_TYPE%"=="BOOT" IF EXIST "%PROG_FOLDER%\RECOVERY_LOCK" COPY /Y "%PROG_FOLDER%\RECOVERY_LOCK" "%APPLYDIR%\$">NUL 2>&1
IF "%UPDATE_TYPE%"=="BOOT" IF NOT EXIST "%PROG_FOLDER%\RECOVERY_LOCK" DEL /Q /F "\\?\%APPLYDIR%\$\RECOVERY_LOCK">NUL 2>&1
IF "%UPDATE_TYPE%"=="BOOT" IF EXIST "%APPLYDIR%\setup.exe" DEL /Q /F "\\?\%APPLYDIR%\setup.exe">NUL 2>&1
REM IF "%UPDATE_TYPE%"=="BOOT" COPY /Y "%APPLYDIR%\Windows\Boot\DVD\EFI\boot.sdi" "%EFI_LETTER%:\Boot">NUL 2>&1
REM IF "%UPDATE_TYPE%"=="BOOT" COPY /Y "%APPLYDIR%\Windows\Boot\EFI\bootmgfw.efi" "%EFI_LETTER%:\EFI\Boot\bootx64.efi">NUL 2>&1
IF "%UPDATE_TYPE%"=="BOOT" (ECHO.[LaunchApp]&&ECHO.AppPath=X:\$\%PROG_NAME%.cmd)>"%APPLYDIR%\Windows\System32\winpeshl.ini"
IF "%UPDATE_TYPE%"=="BOOT" ECHO. Updating boot media %#@%v%VER_Y%%#$% to %#@%v%VER_X%%#$%.
IF "%UPDATE_TYPE%"=="PROG" ECHO. Updating %PROG_NAME%.cmd %#@%v%VER_Y%%#$% to %#@%v%VER_X%%#$%.&© /Y "%PROG_SOURCE%\%PROG_NAME%.cmd" "%APPLYDIR%\$">NUL
IF "%UPDATE_TYPE%"=="PASS" IF DEFINED RECOVERY_LOCK ECHO. Recovery password will be changed to %#@%%RECOVERY_LOCK%%#$%.&&ECHO.%RECOVERY_LOCK%>"%APPLYDIR%\$\RECOVERY_LOCK"
IF "%UPDATE_TYPE%"=="PASS" IF NOT DEFINED RECOVERY_LOCK ECHO. Recovery password will be cleared.&&DEL /Q /F "\\?\%APPLYDIR%\$\RECOVERY_LOCK">NUL 2>&1
IF "%UPDATE_TYPE%"=="WALL" ECHO. Using %PE_WALLPAPER% located in folder for the recovery wallpaper.
IF "%UPDATE_TYPE%"=="WALL" TAKEOWN /F "%APPLYDIR%\Windows\System32\setup.bmp">NUL 2>&1
IF "%UPDATE_TYPE%"=="WALL" ICACLS "%APPLYDIR%\Windows\System32\setup.bmp" /grant %USERNAME%:F>NUL 2>&1
IF "%UPDATE_TYPE%"=="WALL" COPY /Y "%CACHE_FOLDER%\%PE_WALLPAPER%" "%APPLYDIR%\Windows\System32\setup.bmp">NUL 2>&1
IF "%UPDATE_TYPE%"=="HOST" ECHO. Host folder will be changed to %#@%%HOST_FOLDER%%#$%.&&ECHO.%HOST_FOLDER%>"%APPLYDIR%\$\HOST_FOLDER"
ECHO. Saving boot-media...&&DEL /Q /F "%EFI_LETTER%:\$.WIM">NUL 2>&1
SET "IMAGEFILE=%EFI_LETTER%:\$.WIM"&&CALL:CAPTURE_IMAGE
ECHO. Unmounting EFI...&&CALL:VTEMP_DELETE&CALL:EFI_UNMOUNT
GOTO:UPDATE_END
:UPDATE_END
IF "%UPDATE_TYPE%"=="HOST" IF NOT DEFINED ERROR REN "Z:\%HOST_FOLDERX%" "%HOST_FOLDER%">NUL 2>&1
IF NOT DEFINED ERROR FOR %%a in (Z:\%HOST_FOLDER% Z:) DO (ICACLS "%%a" /deny everyone:^(DE,WA,WDAC^)>NUL 2>&1)
IF DEFINED REBOOT_MAN ECHO.&&ECHO. THE SYSTEM WILL NOW RESTART.&&ECHO.&&ECHO. %#@%UPDATE FINISH:%#$% %DATE% %TIME%&&CALL:BOXB2&&CALL:PAUSED&GOTO:QUIT
SET "VER_X="&&SET "VER_Y="&&SET "VER_Z="&&SET "RECOVERY_LOCK="&&GOTO:UPDATE_RECOVERY
:PE_WALLPAPER
CLS&&SET "MENUT0= Recovery Wallpaper"&&SET "MENUT1= "&&SET "MENUT2= %#@%AVAILABLE JPGs/PNGs:%#$%"&&SET "MENUT3= "&&SET "MENUT4= ( %##%.%#$% ) File Operation"&&SET "MENUB0= "&&SET "PICK=CUST"&&SET "$FOLD0=%CACHE_FOLDER%"&&SET "$FILT0=*.JPG *.PNG"&&CALL:FILE_PICK
IF "%SELECT%"=="." SET "FILE_TYPE=WALL"&&CALL:BASIC_FILE&EXIT /B
IF DEFINED $PICK SET "PE_WALLPAPER=%$TRUMP%"
IF NOT DEFINED $PICK SET "PE_WALLPAPER=SELECT"
EXIT /B
:HOST_FOLDER
CALL:PAD_LINE&&CALL:BOXT1&&ECHO.&&ECHO. Enter the host folder name&&ECHO.&&CALL:BOXB1&&CALL:PAD_LINE&&CALL:PAD_PREV&&SET "PROMPT_ANY=1"&&CALL SET "PROMPT_SET=SELECTX"&&CALL:PROMPT_SET
IF NOT DEFINED SELECTX SET "ERROR=1"&&EXIT /B
SET "CHECK=ALPHA"&&SET "CHECK_VAR=%SELECTX%"&&CALL:CHECK
IF DEFINED ERROR CALL:PAUSED
IF NOT DEFINED ERROR SET "HOST_FOLDER=%SELECTX%"
EXIT /B
:VTEMP_CREATE
IF DEFINED ERROR EXIT /B
CALL:SCRATCH_CREATE
ECHO. Mounting temporary vdisk...&&SET "VDISK=%SCRATCHDIR%\scratch.vhdx"&&SET "VDISK_LTR=ANY"&&CALL:VDISK_CREATE>NUL 2>&1
IF NOT EXIST "%VDISK_LTR%:\" SET "ERROR=1"
EXIT /B
:VTEMP_DELETE
IF EXIST "%VDISK_LTR%:\" ECHO. Unmounting temporary vdisk...&&SET "VDISK=%SCRATCHDIR%\scratch.vhdx"&&CALL:VDISK_DETACH>NUL 2>&1
IF EXIST "%PROG_SOURCE%\scratch" CALL:SCRATCH_DELETE
EXIT /B
:SCRATCH_CREATE
IF NOT DEFINED SCRATCHDIR SET "SCRATCHDIR=%PROG_SOURCE%\scratch"
IF EXIST "%SCRATCHDIR%" SET "SCRATCHDIRX=%SCRATCHDIR%"&&CALL:SCRATCH_DELETE
IF DEFINED SCRATCHDIRX SET "SCRATCHDIR=%SCRATCHDIRX%"
IF NOT EXIST "%SCRATCHDIR%" MD "%SCRATCHDIR%">NUL 2>&1
SET "SCRATCHDIRX="
EXIT /B
:SCRATCH_DELETE
IF NOT DEFINED SCRATCHDIR SET "SCRATCHDIR=%PROG_SOURCE%\scratch"
IF EXIST "%SCRATCHDIR%" DISM /cleanup-MountPoints>NUL 2>&1
IF EXIST "%SCRATCHDIR%" ATTRIB -R -S -H "%SCRATCHDIR%" /S /D /L>NUL 2>&1
IF EXIST "%SCRATCHDIR%" RD /S /Q "%SCRATCHDIR%">NUL 2>&1
SET "SCRATCHDIR="
EXIT /B
:APPLY_IMAGE
IF NOT DEFINED IMAGEFILE EXIT /B
IF NOT DEFINED APPLYDIR SET "APPLYDIR=%VDISK_LTR%:"
IF NOT DEFINED IMAGEINDEX SET "IMAGEINDEX=1"
DISM /ENGLISH /APPLY-IMAGE /IMAGEFILE:"%IMAGEFILE%" /INDEX:%IMAGEINDEX% /APPLYDIR:"%APPLYDIR%"&ECHO.&SET "IMAGEFILE="&SET "IMAGEINDEX="
EXIT /B
:CAPTURE_IMAGE
IF NOT DEFINED IMAGEFILE EXIT /B
IF NOT DEFINED CAPTUREDIR SET "CAPTUREDIR=%VDISK_LTR%:"
DISM /ENGLISH /CAPTURE-IMAGE /IMAGEFILE:"%IMAGEFILE%" /CAPTUREDIR:"%CAPTUREDIR%" /NAME:NAME /CheckIntegrity /Verify /Bootable&ECHO.&SET "IMAGEFILE="
EXIT /B
:BASIC_CREATOR
@ECHO OFF&&CLS&&CALL:SETS_HANDLER&&CALL:CLEAN&&CALL:FREE_CALC&&CALL:PAD_LINE&&CALL:BOXT1&&ECHO. deploid&&ECHO.&&SET "SOURCE_LOCATION="&&FOR %%a in (A B C D E F G H I J K L N O P Q R S T U W Y Z) DO (IF EXIST "%%a:\sources\boot.wim" SET "SOURCE_LOCATION=%%a:\sources")
SET "BOOT_EXIST="&&IF EXIST "%BOOT_FOLDER%\BOOT.SAV" SET "BOOT_EXIST=1"
IF "%PROG_MODE%"=="RAMDISK" SET "BOOT_EXIST=1"
SET "WIM_EXIST="&&IF EXIST "%IMAGE_FOLDER%\*.WIM" SET "WIM_EXIST=1"
SET "VHDX_EXIST="&&IF EXIST "%IMAGE_FOLDER%\*.VHDX" SET "VHDX_EXIST=1"
SET "IMAGEPROC_GO="&&FOR %%a in (WIM_EXIST VHDX_EXIST) DO (IF DEFINED %%a SET "IMAGEPROC_GO=1")
SET "BOOTCREATE_GO="&&IF DEFINED BOOT_EXIST IF DEFINED VHDX_EXIST SET "BOOTCREATE_GO=1"
IF DEFINED SOURCE_LOCATION ECHO. (%##%-%#$%) Import Boot %XLR5%Windows Installation Media Detected%#$% Import WIM (%##%+%#$%)&&ECHO.
IF NOT DEFINED IMAGEPROC_GO ECHO. %#@%Insert a Windows Disc/ISO to import installation media%#$%&&ECHO.
IF NOT DEFINED BOOT_EXIST ECHO. %#@%Insert a Windows Disc/ISO to import boot media%#$%&&ECHO.
SET "MENUT0= %#@%AVAILABLE WIMs/VHDXs:%#$%"&&SET "MENUT1= "
IF NOT EXIST "%IMAGE_FOLDER%\*.WIM" IF NOT EXIST "%IMAGE_FOLDER%\*.VHDX" SET "MENUT0="&&SET "MENUT1="
IF EXIST "%IMAGE_FOLDER%\*.WIM" SET "BLIST=WIM"&&CALL:FILE_LIST
IF EXIST "%IMAGE_FOLDER%\*.VHDX" SET "BLIST=VHDX"&&CALL:FILE_LIST
ECHO.&&CALL:BOXB1&&CALL:PAD_LINE&&TITLE deploid v%VER_CUR% (%PROG_SOURCE%)
IF "%PROG_MODE%"=="RAMDISK" IF DEFINED IMAGEPROC_GO IF NOT DEFINED BOOTCREATE_GO ECHO. (%##%C%#$%)onvert&&CALL:PAD_LINE
IF "%PROG_MODE%"=="RAMDISK" IF DEFINED IMAGEPROC_GO IF DEFINED BOOTCREATE_GO ECHO. (%##%C%#$%)onvert (%##%G%#$%)o^^!&&CALL:PAD_LINE
IF "%PROG_MODE%"=="PORTABLE" IF DEFINED IMAGEPROC_GO IF NOT DEFINED BOOTCREATE_GO ECHO. (%##%Q%#$%)uit (%##%*%#$%) Settings (%##%C%#$%)onvert %#@%%FREE%GB%#$% Free&&CALL:PAD_LINE
IF "%PROG_MODE%"=="PORTABLE" IF DEFINED IMAGEPROC_GO IF DEFINED BOOTCREATE_GO ECHO. (%##%Q%#$%)uit (%##%*%#$%) Settings (%##%C%#$%)onvert (%##%G%#$%)o^^! %#@%%FREE%GB%#$% Free&&CALL:PAD_LINE
IF "%PROG_MODE%"=="RAMDISK" CALL:PAD_PREV
CALL:MENU_SELECT
IF NOT DEFINED SELECT IF "%PROG_MODE%"=="RAMDISK" GOTO:MAIN_MENU
IF DEFINED HOST_ERROR IF "%PROG_MODE%"=="RAMDISK" GOTO:MAIN_MENU
IF "%SELECT%"=="Q" GOTO:QUIT
IF "%SELECT%"=="C" CALL:CONVERT_PROMPT&SET "SELECT="
IF "%SELECT%"=="+" IF DEFINED SOURCE_LOCATION CALL:SOURCE_IMPORT&SET "SELECT="
IF "%SELECT%"=="-" IF DEFINED SOURCE_LOCATION CALL:BOOT_IMPORT&SET "SELECT="
IF "%SELECT%"=="G" IF "%PROG_MODE%"=="RAMDISK" IF NOT EXIST "%BOOT_FOLDER%\boot.sav" CALL:BOOT_FETCH
IF "%SELECT%"=="G" IF EXIST "%BOOT_FOLDER%\boot.sav" CALL:CREATOR_PROMPT&SET "SELECT="
IF "%SELECT%"=="*" IF "%PROG_MODE%"=="PORTABLE" GOTO:SETTINGS_MENU
GOTO:BASIC_CREATOR
:CREATOR_PROMPT
SET "$VHDX=X"&&CALL:VHDX_CHECK
IF DEFINED ERROR EXIT /B
SET "QUERY_MSG= %XLR2%Select a disk to erase%#$%"&&CALL:DISK_MENU
IF DEFINED ERROR EXIT /B
CALL:CONFIRM
IF NOT "%CONFIRM%"=="X" EXIT /B
IF DEFINED DISK_NUMBER IF DEFINED DISK_TARGET CALL:BOOT_CREATOR_START&CALL:PAUSED
EXIT /B
:CONVERT_PROMPT
SET "MENUT0= Image Processing"&&SET "MENUT1= "&&SET "MENUT2= %#@%AVAILABLE WIMs/VHDXs:%#$%"&&SET "MENUT3= "&&SET "MENUT4= ( %##%.%#$% ) File Operation"&&SET "MENUB0= "&&SET "PICK=CUST"&&SET "$FOLD0=%IMAGE_FOLDER%"&&SET "$FILT0=*.WIM *.VHDX"&&CALL:FILE_PICK
IF "%SELECT%"=="." SET "FILE_TYPE=IMAGE"&&CALL:BASIC_FILE&EXIT /B
IF NOT DEFINED $PICK EXIT /B
SET "CONVERT_EXT="&&FOR %%G in ("%$PICK%") DO (SET "CAPS_SET=CONVERT_EXT"&&SET "CAPS_VAR=%%~xG"&&CALL:CAPS_SET)
IF "%CONVERT_EXT%"==".WIM" GOTO:BASIC_RESTORE_X
IF "%CONVERT_EXT%"==".VHDX" GOTO:BASIC_BACKUP_X
EXIT /B
:BASIC_BACKUP
SET "MENUT0= Image Processing"&&SET "MENUT1= "&&SET "MENUT2= %#@%AVAILABLE VHDXs:%#$%"&&SET "MENUT3= "&&SET "MENUT4= ( %##%.%#$% ) File Operation"&&SET "MENUB0= "&&SET "PICK=VHDX"&&CALL:FILE_PICK
IF "%SELECT%"=="." SET "FILE_TYPE=VHDX"&&CALL:BASIC_FILE&EXIT /B
IF NOT DEFINED $PICK EXIT /B
:BASIC_BACKUP_X
SET "VHDX_SOURCE=%$PICK_BODY%%$PICK_EXT%"
SET "SOURCE_TYPE=VHDX"&&SET "TARGET_TYPE=WIM"&&CALL:IMAGEPROC_TARGET
IF NOT DEFINED WIM_TARGET EXIT /B
IF EXIST "%IMAGE_FOLDER%\%WIM_TARGET%" ECHO.&&ECHO. %XLR4%ERROR:%#$% File already exists.&&EXIT /B
SET "WIM_INDEX=1"&&CALL:IMAGEPROC_START
EXIT /B
:BASIC_RESTORE
SET "MENUT0= Image Processing"&&SET "MENUT1= "&&SET "MENUT2= %#@%AVAILABLE WIMs:%#$%"&&SET "MENUT3= "&&SET "MENUT4= ( %##%.%#$% ) File Operation"&&SET "MENUB0= "&&SET "PICK=WIM"&&CALL:FILE_PICK
IF "%SELECT%"=="." SET "FILE_TYPE=WIM"&&CALL:BASIC_FILE&EXIT /B
IF NOT DEFINED $PICK EXIT /B
:BASIC_RESTORE_X
SET "WIM_SOURCE=%$PICK_BODY%%$PICK_EXT%"
CALL:WIM_INDEX_MENU
IF DEFINED ERROR EXIT /B
SET "SOURCE_TYPE=WIM"&&SET "TARGET_TYPE=VHDX"&&CALL:IMAGEPROC_TARGET
IF NOT DEFINED VHDX_TARGET EXIT /B
IF NOT EXIST "%IMAGE_FOLDER%\%VHDX_TARGET%" CALL:IMAGEPROC_VSIZE
IF DEFINED ERROR EXIT /B
CALL:IMAGEPROC_START
EXIT /B
::#########################################################################
:IMAGEPROC_START
::#########################################################################
SET "VHDX_MB=%VHDX_SIZE%"&&CLS&&CALL:BOXT2&&ECHO. %#@%IMAGE PROCESSING START:%#$% %DATE% %TIME%
IF "%TARGET_TYPE%"=="WIM" IF EXIST "%IMAGE_FOLDER%\%WIM_TARGET%" ECHO.&&ECHO. %XLR4%Target %WIM_TARGET% exists. Try another name or delete the existing file.%#$%&&GOTO:IMAGEPROC_END
IF "%TARGET_TYPE%"=="VHDX" IF EXIST "%IMAGE_FOLDER%\%VHDX_TARGET%" ECHO.&&ECHO. File %#@%%VHDX_TARGET%%#$% already exists.&&ECHO. %XLR2%Note:%#$% Updating may cause errors. Try a new vhdx if having issues.&&ECHO.&&ECHO. Press (%##%X%#$%) to overwrite.&&ECHO.&&CALL:PAD_PREV&&CALL SET "PROMPT_SET=CONFIRM"&&CALL:PROMPT_SET
IF "%TARGET_TYPE%"=="VHDX" IF EXIST "%IMAGE_FOLDER%\%VHDX_TARGET%" IF NOT "%CONFIRM%"=="X" ECHO.&&ECHO. %##%Abort.%#$%&&GOTO:IMAGEPROC_END
IF NOT DEFINED WIM_INDEX SET "WIM_INDEX=1"
IF "%SOURCE_TYPE%"=="WIM" IF "%TARGET_TYPE%"=="VHDX" CALL:WIM2VHDX
IF "%SOURCE_TYPE%"=="VHDX" IF "%TARGET_TYPE%"=="WIM" CALL:VHDX2WIM
:IMAGEPROC_END
ECHO.&&ECHO. %#@%IMAGE PROCESSING END:%#$% %DATE% %TIME%&&CALL:BOXB2&&CALL:PAUSED
EXIT /B
:WIM2VHDX
ECHO.&&IF EXIST "%IMAGE_FOLDER%\%VHDX_TARGET%" SET "VDISK=%IMAGE_FOLDER%\%VHDX_TARGET%"&&SET "VDISK_LTR=ANY"&&CALL:VDISK_ATTACH
IF NOT EXIST "%IMAGE_FOLDER%\%VHDX_TARGET%" SET "VDISK=%IMAGE_FOLDER%\%VHDX_TARGET%"&&SET "VDISK_LTR=ANY"&&CALL:VDISK_CREATE
IF NOT EXIST "%VDISK_LTR%:\" ECHO.&&ECHO. %XLR4%Vdisk Error. If VHDX refuses mounting, try another.%#$%
IF EXIST "%VDISK_LTR%:\" DISM /ENGLISH /APPLY-IMAGE /IMAGEFILE:"%IMAGE_FOLDER%\%WIM_SOURCE%" /INDEX:%WIM_INDEX% /APPLYDIR:"%VDISK_LTR%:"
ECHO.&&CALL:VDISK_DETACH
EXIT /B
:VHDX2WIM
SET "NAME_TMP="&&FOR /F "TOKENS=1-2* DELIMS=:<> " %%a in ('DISM /ENGLISH /Get-ImageInfo /ImageFile:"%IMAGE_FOLDER%\%VHDX_SOURCE%" /INDEX:1 2^>NUL') DO (IF "%%a"=="Edition" SET "NAME_TMP=%%b")
IF NOT DEFINED NAME_TMP SET "NAME_TMP=Index 1"
ECHO.&&SET "VDISK=%IMAGE_FOLDER%\%VHDX_SOURCE%"&&SET "VDISK_LTR=ANY"&&CALL:VDISK_ATTACH
IF NOT EXIST "%VDISK_LTR%:\" ECHO.&&ECHO. %XLR4%Vdisk Error. If VHDX refuses mounting, try another.%#$%
IF EXIST "%VDISK_LTR%:\" DISM /ENGLISH /CAPTURE-IMAGE /CAPTUREDIR:"%VDISK_LTR%:" /IMAGEFILE:"%IMAGE_FOLDER%\%WIM_TARGET%" /COMPRESS:%WIM_XLVL% /NAME:"%NAME_TMP%"
ECHO.&&CALL:VDISK_DETACH
EXIT /B
:BOOT_IMPORT
IF EXIST "%BOOT_FOLDER%\boot.sav" CALL:PAD_LINE&&CALL:BOXT1&&ECHO.&&ECHO. File boot.sav already exists. Press (%##%X%#$%) to overwrite.&&ECHO.&&CALL:BOXB1&&CALL:PAD_LINE&&CALL:PAD_PREV&&CALL SET "PROMPT_SET=CONFIRM"&&CALL:PROMPT_SET
IF EXIST "%BOOT_FOLDER%\boot.sav" IF NOT "%CONFIRM%"=="X" EXIT /B
IF EXIST "%SOURCE_LOCATION%\boot.wim" ECHO.Importing %#@%boot.wim%#$% to boot.sav...&© /Y "%SOURCE_LOCATION%\boot.wim" "%BOOT_FOLDER%\boot.sav"
EXIT /B
:SOURCE_IMPORT
SET "WIM_EXT="&&FOR %%G in (wim esd) DO (IF EXIST "%SOURCE_LOCATION%\install.%%G" SET "WIM_EXT=%%G")
IF EXIST "%SOURCE_LOCATION%\install.%WIM_EXT%" ECHO.&&CALL:PAD_LINE&&CALL:BOXT1&&ECHO.&&ECHO. Enter name of new .WIM&&ECHO.&&CALL:BOXB1&&CALL:PAD_LINE&&CALL:PAD_PREV&&SET "PROMPT_SET=NEW_NAME"&&SET "PROMPT_ANY=1"&&CALL:PROMPT_SET
IF NOT DEFINED NEW_NAME EXIT /B
IF EXIST "%IMAGE_FOLDER%\%NEW_NAME%.wim" CALL:PAD_LINE&&CALL:BOXT1&&ECHO.&&ECHO. File %NEW_NAME%.wim already exists. Press (%##%X%#$%) to overwrite.&&ECHO.&&CALL:BOXB1&&CALL:PAD_LINE&&CALL:PAD_PREV&&CALL SET "PROMPT_SET=CONFIRM"&&CALL:PROMPT_SET
IF EXIST "%IMAGE_FOLDER%\%NEW_NAME%.wim" IF NOT "%CONFIRM%"=="X" EXIT /B
IF DEFINED NEW_NAME ECHO.Copying install.%WIM_EXT% to %#@%%NEW_NAME%.wim%#$%...&© /Y "%SOURCE_LOCATION%\install.%WIM_EXT%" "%IMAGE_FOLDER%\%NEW_NAME%.wim"&&SET "NEW_NAME="
EXIT /B
:IMAGEPROC_XLVL
IF "%WIM_XLVL%"=="FAST" SET "WIM_XLVL=MAX"&&EXIT /B
IF "%WIM_XLVL%"=="MAX" SET "WIM_XLVL=NONE"&&EXIT /B
IF "%WIM_XLVL%"=="NONE" SET "WIM_XLVL=FAST"&&EXIT /B
EXIT /B
:IMAGEPROC_VSIZE
CALL:PAD_LINE&&CALL:BOXT1&&ECHO.&&ECHO. Enter new VHDX size in GB&&ECHO. Note: 25GB or greater is recommended&&ECHO.&&CALL:BOXB1&&CALL:PAD_LINE&&CALL:PAD_PREV&&SET "PROMPT_SET=SELECTX"&&CALL:PROMPT_SET
SET "CHECK=NUM"&&SET "CHECK_VAR=%SELECTX%"&&CALL:CHECK
IF DEFINED ERROR EXIT /B
IF %SELECTX% LSS 1 SET "ERROR=1"
IF %SELECTX% GTR 9999 SET "ERROR=1"
IF NOT DEFINED ERROR IF %SELECTX% LSS 25 CALL:CONFIRM
IF NOT DEFINED ERROR IF %SELECTX% LSS 25 IF NOT "%CONFIRM%"=="X" SET "ERROR=1"
IF NOT DEFINED ERROR SET "VHDX_SIZE=%SELECTX%000"
EXIT /B
:IMAGEPROC_TARGET
CALL:PAD_LINE&&CALL:BOXT1&&ECHO.&&ECHO. Enter name of new .%TARGET_TYPE%&&ECHO.&&CALL:BOXB1&&CALL:PAD_LINE&&CALL:PAD_PREV&&SET "PROMPT_SET=SELECTX"&&SET "PROMPT_ANY=1"&&CALL:PROMPT_SET
IF NOT DEFINED SELECTX SET "%TARGET_TYPE%_TARGET="
IF "%TARGET_TYPE%"=="WIM" IF DEFINED SELECTX SET "WIM_TARGET=%SELECTX%.wim"
IF "%TARGET_TYPE%"=="VHDX" IF DEFINED SELECTX SET "VHDX_TARGET=%SELECTX%.vhdx"
EXIT /B
:IMAGEPROC_SOURCE
SET "MENUT0= Image Processing"&&SET "MENUT1= "&&SET "MENUT2= %#@%AVAILABLE %SOURCE_TYPE%s:%#$%"&&SET "MENUT3= "&&SET "MENUT4= ( %##%.%#$% ) File Operation"&&SET "MENUB0= "&&SET "PICK=%SOURCE_TYPE%"&&CALL:FILE_PICK
IF "%SELECT%"=="." SET "FILE_TYPE=%SOURCE_TYPE%"&&CALL:BASIC_FILE&EXIT /B
CALL SET "%SOURCE_TYPE%_SOURCE=%$TRUMP%"
EXIT /B
:WIM_INDEX_MENU
CLS&&CALL:PAD_LINE&&CALL:BOXT1&&ECHO. Image Processing&&ECHO.&&ECHO. %#@%AVAILABLE INDEXs:%#$%&&ECHO.&&SET "INDEX_TMP="&&SET "NAME_TMP="&&FOR /F "TOKENS=1-9 DELIMS=: " %%a in ('DISM /ENGLISH /Get-ImageInfo /ImageFile:"%IMAGE_FOLDER%\%WIM_SOURCE%" 2^>NUL') DO (
IF "%%a"=="Index" CALL SET "INDEX_TMP=%%b"
IF "%%a"=="Name" CALL SET "NAME_TMP=%%b %%c %%d %%e %%f %%g %%h %%i"&&CALL:WIM_INDEX_LIST)
IF NOT DEFINED INDEX_TMP ECHO.%XLR2%ERROR%#$%&&SET "ERROR=1"&&EXIT /B
ECHO.&&CALL:BOXB1&&CALL:PAD_LINE&&CALL:PAD_PREV&&CALL:MENU_SELECT
IF NOT DEFINED SELECT SET "ERROR=1"&&EXIT /B
SET "WIM_INDEX=%SELECT%"&&CALL:WIM_INDEX_QUERY
IF "%WIM_DESC%"=="NULL" ECHO.&&ECHO. %XLR2%ERROR%#$%&&SET "ERROR=1"
EXIT /B
:WIM_INDEX_LIST
ECHO. ( %##%%INDEX_TMP%%#$% ) %NAME_TMP%
EXIT /B
:WIM_INDEX_QUERY
SET "WIM_DESC="&&FOR /F "TOKENS=1-5 DELIMS=<> " %%a in ('DISM /ENGLISH /Get-ImageInfo /ImageFile:"%IMAGE_FOLDER%\%WIM_SOURCE%" /Index:%WIM_INDEX% 2^>NUL') DO (IF "%%a"=="Edition" SET "WIM_DESC=%%c")
IF NOT DEFINED WIM_DESC SET "WIM_INDEX=1"&&SET "WIM_DESC=NULL"
EXIT /B
::#########################################################################
:BASIC_FILE
::#########################################################################
IF DEFINED FILE_OPER GOTO:BASIC_FILETYPE
CLS&&CALL:PAD_LINE&&CALL:BOXT1&&ECHO. File Operation&&ECHO.&&ECHO. (%##%1%#$%) Rename&&ECHO. (%##%2%#$%) Delete&&ECHO. (%##%3%#$%) Copy
ECHO.&&CALL:BOXB1&&CALL:PAD_LINE&&CALL:PAD_PREV&&SET "PROMPT_SET=FILE_PROMPT"&&CALL:PROMPT_SET
IF "%FILE_PROMPT%"=="1" SET "FILE_OPER=Rename"
IF "%FILE_PROMPT%"=="2" SET "FILE_OPER=Delete"
IF "%FILE_PROMPT%"=="3" SET "FILE_OPER=Copy"
IF NOT DEFINED FILE_OPER GOTO:BASIC_ERROR
:BASIC_FILETYPE
IF DEFINED FILE_SKIP GOTO:BASIC_FILEOPER
:BASIC_FILEPICK
FOR %%X in (WIM VHDX ISO LIST BASE CAB MSU PKX APPX APPXBUNDLE MSIXBUNDLE) DO (IF "%%X"=="%FILE_TYPE%" SET "MENUT0= File %FILE_OPER%"&&SET "MENUT1= "&&SET "MENUT2= %#@%AVAILABLE %%Xs:%#$%"&&SET "MENUT3= "&&SET "MENUB0= "&&SET "PICK=%%X"&&CALL:FILE_PICK)
IF "%FILE_TYPE%"=="WALL" SET "MENUT0= File %FILE_OPER%"&&SET "MENUT1= "&&SET "MENUT2= %#@%AVAILABLE JPGs/PNGs:%#$%"&&SET "MENUT3= "&&SET "MENUB0= "&&SET "PICK=CUST"&&SET "$FOLD0=%CACHE_FOLDER%"&&SET "$FILT0=*.JPG *.PNG"&&CALL:FILE_PICK
IF "%FILE_TYPE%"=="MAIN" SET "MENUT0= File %FILE_OPER%"&&SET "MENUT1= "&&SET "MENUT2= %#@%MAIN FOLDER VHDXs:%#$%"&&SET "MENUT3= "&&SET "MENUB0= "&&SET "PICK=CUST"&&SET "$FOLD0=%PROG_SOURCE%"&&SET "$FILT0=*.VHDX"&&CALL:FILE_PICK
IF "%FILE_TYPE%"=="IMAGE" SET "MENUT0= File %FILE_OPER%"&&SET "MENUT1= "&&SET "MENUT2= %#@%AVAILABLE WIMs/VHDXs:%#$%"&&SET "MENUT3= "&&SET "MENUB0= "&&SET "PICK=CUST"&&SET "$FOLD0=%IMAGE_FOLDER%"&&SET "$FILT0=*.WIM *.VHDX"&&CALL:FILE_PICK
IF NOT DEFINED $PICK GOTO:BASIC_ERROR
:BASIC_FILEOPER
IF "%FILE_OPER%"=="Delete" CALL:CONFIRM
IF "%FILE_OPER%"=="Delete" IF "%CONFIRM%"=="X" DEL /Q /F "%$PICK%">NUL
IF "%FILE_OPER%"=="Delete" GOTO:BASIC_ERROR
CALL:PAD_LINE&&CALL:BOXT1&&ECHO.&&ECHO. Enter new name of %$PICK_EXT%&&ECHO.&&CALL:BOXB1&&CALL:PAD_LINE&&CALL:PAD_PREV&&SET "PROMPT_SET=FILE_PROMPT"&&SET "PROMPT_ANY=1"&&CALL:PROMPT_SET
IF NOT DEFINED FILE_PROMPT GOTO:BASIC_ERROR
IF EXIST "%$PICK_PATH%\%FILE_PROMPT%%$PICK_EXT%" GOTO:BASIC_ERROR
SET "CASE=LOWER"&&SET "CAPS_SET=$PICK_EXT"&&SET "CAPS_VAR=%$PICK_EXT%"&&CALL:CAPS_SET
IF "%FILE_OPER%"=="Rename" REN "%$PICK%" "%FILE_PROMPT%%$PICK_EXT%">NUL 2>&1
IF "%FILE_OPER%"=="Copy" ECHO.Copying %FILE_PROMPT%%$PICK_EXT%...&© /Y "%$PICK%" "%$PICK_PATH%%FILE_PROMPT%%$PICK_EXT%">NUL 2>&1
:BASIC_ERROR
SET "FILE_OPER="&&SET "FILE_TYPE="&&SET "FILE_NAME="&&SET "FILE_SKIP="&&SET "$PICK="
EXIT /B
:DISK_UID
FOR %%a in (DISK_X UID_X) DO (IF NOT DEFINED %%a EXIT /B)
(ECHO.select disk %DISK_X%&&ECHO.uniqueid disk id=%UID_X%&&ECHO.Exit)>"$DSK"&&DISKPART /s "$DSK"
SET "DISK_X="&&SET "UID_X="&&CALL:DEL_DSK&&EXIT /B
:PART_ASSIGN
FOR %%a in (DISK_X PART_X LETT_X) DO (IF NOT DEFINED %%a EXIT /B)
(ECHO.select disk %DISK_X%&&ECHO.select partition %PART_X%&&ECHO.assign letter=%LETT_X% noerr&&ECHO.Exit)>"$DSK"&&DISKPART /s "$DSK">NUL 2>&1
SET "DISK_X="&&SET "PART_X="&&SET "SIZE_X="&&CALL:DEL_DSK&&EXIT /B
:VOL_REMOVE
FOR %%a in (LETT_X) DO (IF NOT DEFINED %%a EXIT /B)
(ECHO.select VOLUME %LETT_X%&&ECHO.Remove letter=%LETT_X% noerr&&ECHO.Exit)>"$DSK"&&DISKPART /s "$DSK">NUL 2>&1
SET "DISK_X="&&SET "PART_X="&&SET "LETT_X="&&SET "SIZE_X="&&CALL:DEL_DSK&&EXIT /B
:PART_REMOVE
FOR %%a in (DISK_X PART_X LETT_X) DO (IF NOT DEFINED %%a EXIT /B)
(ECHO.select disk %DISK_X%&&ECHO.select partition %PART_X%&&ECHO.Remove letter=%LETT_X% noerr&&ECHO.Exit)>"$DSK"&&DISKPART /s "$DSK">NUL 2>&1
SET "DISK_X="&&SET "PART_X="&&SET "LETT_X="&&SET "SIZE_X="&&CALL:DEL_DSK&&EXIT /B
:PART_4000
FOR %%a in (DISK_X PART_X) DO (IF NOT DEFINED %%a EXIT /B)
(ECHO.select disk %DISK_X%&&ECHO.select partition %PART_X%&&ECHO.gpt attributes=0x4000000000000001&&ECHO.Exit)>"$DSK"&&DISKPART /s "$DSK">NUL 2>&1
SET "DISK_X="&&SET "PART_X="&&SET "LETT_X="&&SET "SIZE_X="&&CALL:DEL_DSK&&EXIT /B
:PART_8000
FOR %%a in (DISK_X PART_X) DO (IF NOT DEFINED %%a EXIT /B)
(ECHO.select disk %DISK_X%&&ECHO.select partition %PART_X%&&ECHO.gpt attributes=0x0000000000000000&&ECHO.Exit)>"$DSK"&&DISKPART /s "$DSK">NUL 2>&1
SET "DISK_X="&&SET "PART_X="&&SET "LETT_X="&&SET "SIZE_X="&&CALL:DEL_DSK&&EXIT /B
:PART_EFIX
FOR %%a in (DISK_X PART_X) DO (IF NOT DEFINED %%a EXIT /B)
(ECHO.select disk %DISK_X%&&ECHO.select partition %PART_X%&&ECHO.set id=c12a7328-f81f-11d2-ba4b-00a0c93ec93b override&&ECHO.Exit)>"$DSK"&&DISKPART /s "$DSK">NUL 2>&1
SET "DISK_X="&&SET "PART_X="&&SET "LETT_X="&&SET "SIZE_X="&&CALL:DEL_DSK&&EXIT /B
:PART_BAS
FOR %%a in (DISK_X PART_X) DO (IF NOT DEFINED %%a EXIT /B)
(ECHO.select disk %DISK_X%&&ECHO.select partition %PART_X%&&ECHO.set id=ebd0a0a2-b9e5-4433-87c0-68b6b72699c7 override&&ECHO.Exit)>"$DSK"&&DISKPART /s "$DSK">NUL 2>&1
SET "DISK_X="&&SET "PART_X="&&SET "LETT_X="&&SET "SIZE_X="&&CALL:DEL_DSK&&EXIT /B
:PART_PRIMARY
FOR %%a in (DISK_X) DO (IF NOT DEFINED %%a EXIT /B)
IF DEFINED SIZE_X SET "SIZE_X= size=%SIZE_X%"
(ECHO.select disk %DISK_X%&&ECHO.create partition primary%SIZE_X%&&ECHO.format quick fs=ntfs&&ECHO.Exit)>"$DSK"&&DISKPART /s "$DSK">NUL 2>&1
SET "DISK_X="&&SET "PART_X="&&SET "SIZE_X="&&CALL:DEL_DSK&&EXIT /B
:DISK_CLEAN
FOR %%a in (DISK_X) DO (IF NOT DEFINED %%a EXIT /B)
(ECHO.select disk %DISK_X%&&ECHO.clean&&ECHO.convert gpt&&ECHO.select partition 1&&ECHO.delete partition override&&ECHO.Exit)>"$DSK"&&DISKPART /s "$DSK">NUL
SET "DISK_X="&&SET "PART_X="&&SET "LETT_X="&&SET "SIZE_X="&&CALL:DEL_DSK&&EXIT /B
:DEL_DSK
IF EXIST "$DSK" DEL /Q /F "$DSK">NUL
EXIT /B
:BOOT_FETCH
CALL:PAD_LINE&&CALL:BOXT1&&ECHO.&&ECHO. File boot.sav doesn't exist. Press (%##%X%#$%) to copy from recovery&&ECHO.&&CALL:BOXB1&&CALL:PAD_LINE&&CALL:PAD_PREV&&CALL SET "PROMPT_SET=CONFIRM"&&CALL:PROMPT_SET
IF NOT "%CONFIRM%"=="X" EXIT /B
CALL:EFI_MOUNT&&CALL:PAD_LINE
ECHO. Copying %#@%boot.sav%#$%...&© /Y "%EFI_LETTER%:\$.WIM" "%BOOT_FOLDER%\boot.sav">NUL 2>&1
CALL:EFI_UNMOUNT
EXIT /B
:CONFIRM
IF DEFINED ERROR EXIT /B
CALL:PAD_LINE&&CALL:BOXT1&&ECHO.&&ECHO. %XLR4%Are you sure?%#$% Press (%##%X%#$%) to proceed&&ECHO.&&CALL:BOXB1&&CALL:PAD_LINE&&CALL:PAD_PREV&&CALL SET "PROMPT_SET=CONFIRM"&&CALL:PROMPT_SET
IF NOT "%CONFIRM%"=="X" SET "ERROR=1"
EXIT /B
:VDISK_CREATE
IF NOT DEFINED VDISK EXIT /B
IF NOT DEFINED VDISK_LTR SET "VDISK_LTR=ANY"
IF "%VDISK_LTR%"=="ANY" SET "$GET=VDISK_LTR"&&CALL:LETTER_ANY
FOR %%G in ("%VDISK%") DO (SET "VHDX_123=%%~nG%%~xG")
ECHO. Mounting vdisk %VHDX_123% letter %VDISK_LTR%...&&SET "VHDX_123="
IF NOT DEFINED VHDX_MB SET "VHDX_MB=25600"
(ECHO.create vdisk file="%VDISK%" maximum=%VHDX_MB% type=expandable&&ECHO.select vdisk file="%VDISK%"&&ECHO.attach vdisk&&ECHO.create partition primary&&ECHO.select partition 1&&ECHO.format fs=ntfs quick&&ECHO.assign letter=%VDISK_LTR% noerr&&ECHO.Exit)>"$DSK"&&DISKPART /s "$DSK">NUL 2>&1
SET "VHDX_MB="&&IF EXIST "$DSK*" DEL /Q /F "$DSK*">NUL 2>&1
IF EXIST "%VDISK_LTR%:\" SET "VDISK_ATTACHED=1"
EXIT /B
:VDISK_ATTACH
IF NOT DEFINED VDISK EXIT /B
IF NOT DEFINED VDISK_LTR SET "VDISK_LTR=ANY"
IF "%VDISK_LTR%"=="ANY" SET "$GET=VDISK_LTR"&&CALL:LETTER_ANY
FOR %%G in ("%VDISK%") DO (SET "VHDX_123=%%~nG%%~xG")
ECHO. Mounting vdisk %VHDX_123% letter %VDISK_LTR%...&&SET "VHDX_123="
SET "VDISK_SYS="&&(ECHO.Select vdisk file="%VDISK%"&&ECHO.attach vdisk&&ECHO.list vdisk&&ECHO.Exit)>"$DSK"
FOR /F "TOKENS=1-8* DELIMS=* " %%a IN ('DISKPART /s "$DSK"') DO (SET "DISK_NUM="&&IF "%%a"=="VDisk" IF EXIST "%%i" SET "DISK_NUM=%%d"&&SET "CAPS_SET=VDISK_QRY"&&SET "CAPS_VAR=%%i"&&CALL:CAPS_SET&&CALL:VDISK_CAPS)
IF EXIST "%VDISK_LTR%:\" SET "VDISK_ATTACHED=1"&&IF EXIST "%VDISK_LTR%:\WINDOWS" SET "VDISK_SYS=1"
SET "VDISK_PART="&&SET "VDISK_QRY="&&SET "DISK_NUM="&&IF EXIST "$DSK*" DEL /Q /F "$DSK*">NUL 2>&1
EXIT /B
:VDISK_CAPS
SET "CAPS_SET=VDISK"&&SET "CAPS_VAR=%VDISK%"&&CALL:CAPS_SET
IF NOT "%VDISK_QRY%"=="%VDISK%" EXIT /B
(ECHO.select disk %DISK_NUM%&&ECHO.list partition&&ECHO.Exit)>"$DSK"&&FOR /F "TOKENS=1-8* DELIMS=* " %%1 IN ('DISKPART /s "$DSK"') DO (IF "%%1"=="Partition" IF NOT "%%2"=="" IF NOT "%%2"=="###" SET "VDISK_PART=%%2")
IF DEFINED VDISK_PART (ECHO.Select vdisk file="%VDISK%"&&ECHO.select partition %VDISK_PART%&&ECHO.assign letter=%VDISK_LTR% noerr&&ECHO.Exit)>"$DSK"&&DISKPART /s "$DSK">NUL 2>&1
EXIT /B
:VDISK_DETACH
IF NOT DEFINED VDISK EXIT /B
FOR %%G in ("%VDISK%") DO (SET "VHDX_123=%%~nG%%~xG")
ECHO. Unmounting vdisk %VHDX_123% letter %VDISK_LTR%...&&SET "VHDX_123="
(ECHO.Select vdisk file="%VDISK%"&&ECHO.Detach vdisk&&ECHO.Exit)>"$DSK"&&DISKPART /s "$DSK">NUL 2>&1
IF NOT EXIST "%VDISK_LTR%:\" SET "VDISK_ATTACHED="
IF EXIST "$DSK*" DEL /Q /F "$DSK*">NUL 2>&1
EXIT /B
:LETTER_ANY
IF NOT DEFINED $GET EXIT /B
FOR %%G in (Z Y X W V U T S R Q P O N M L K J I H G F E D) DO (IF NOT EXIST "%%G:\" SET "%$GET%=%%G")
SET "$GET="&&EXIT /B
:DISKMGR_ERASE
IF DEFINED ERROR EXIT /B
FOR %%a in (DISK_NUMBER) DO (IF NOT DEFINED %%a EXIT /B)
FOR %%a in (0 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) DO (IF "%DISK_NUMBER%"=="%%a" CALL SET "GET_DISK_ID=%%DISKID_%%a%%")
SET "DISK_X=%DISK_NUMBER%"&&CALL:DISK_CLEAN&&SET "DISK_X=%DISK_NUMBER%"&&SET "PART_X=1"&&SET "LETT_X=%TST_LETTER%"&&CALL:PART_ASSIGN
IF EXIST "%TST_LETTER%:\" SET "DISK_X=%DISK_NUMBER%"&&CALL:DISK_CLEAN
CALL:DISKMGR_CHANGEID>NUL 2>&1
IF NOT EXIST "%TST_LETTER%:\" SET "DISK_MSG=All partitions on Disk %DISK_NUMBER% have been erased."
IF EXIST "%TST_LETTER%:\" SET "DISK_MSG=%##%Disk %DISK_NUMBER% is currently in use - unplug disk - reboot into Windows - replug and try again.%#$%"
IF EXIST "%TST_LETTER%:\" SET "LETT_X=%TST_LETTER%"&&CALL:VOL_REMOVE
IF EXIST "%TST_LETTER%:\" SET "DISK_X=%DISK_NUMBER%"&&SET "PART_X=1"&&SET "LETT_X=%TST_LETTER%"&&CALL:PART_REMOVE
SET "TEST_X="&&EXIT /B
:DISK_UID_PROMPT
ECHO. Enter a new disk UID (%##%#%#$%) &&CALL:PAD_LINE&&CALL:PAD_PREV&&CALL:MENU_SELECT
IF NOT DEFINED SELECT SET "ERROR=1"&&EXIT /B
IF NOT DEFINED ERROR SET "GET_DISK_ID=%SELECT%"&&CALL:CONFIRM&&CALL:DISKMGR_CHANGEID
EXIT /B
:DISKMGR_CHANGEID
IF DEFINED ERROR EXIT /B
FOR %%a in (DISK_NUMBER GET_DISK_ID) DO (IF NOT DEFINED %%a EXIT /B)
SET "UID_XNT="&&FOR /F "DELIMS=" %%G in ('CMD.EXE /D /U /C ECHO.%GET_DISK_ID%^| FIND /V ""') do (CALL SET /A "UID_XNT+=1")
IF NOT "%UID_XNT%"=="36" SET "GET_DISK_ID=00000000-0000-0000-0000-000000000000"
SET "UID_X=%GET_DISK_ID%"&&SET "DISK_X=%DISK_NUMBER%"&&CALL:DISK_UID
EXIT /B
:HOST_HIDE
ECHO. Hiding the vhdx host partition...&&SET /P DISK_TARGET=<"%PROG_FOLDER%\HOST_TARGET"&&CALL:DISK_DETECT>NUL 2>&1
IF NOT DEFINED DISK_DETECT EXIT /B
SET "DISK_X=%DISK_DETECT%"&&SET "PART_X=2"&&SET "LETT_X=Z"&&CALL:PART_REMOVE&&SET "DISK_X=%DISK_DETECT%"&&SET "PART_X=2"&&CALL:PART_4000
EXIT /B
:HOST_AUTO
SET "PROG_NAME=deploid"&&SET "HOST_ERROR="&&IF NOT DEFINED ARBIT_FLAG CLS&&ECHO.Querying disks...
IF EXIST "Z:\" (ECHO.select volume Z&&ECHO.remove letter=Z noerr&&ECHO.exit)>"$DSK"&&DISKPART /s "$DSK">NUL 2>&1
IF EXIST "%PROG_FOLDER%\HOST_FOLDER" SET /P HOST_FOLDERX=<"%PROG_FOLDER%\HOST_FOLDER"
IF NOT DEFINED HOST_FOLDERX SET "HOST_FOLDERX=$"
SET /P HOST_TARGET=<"%PROG_FOLDER%\HOST_TARGET"
SET "DISK_TARGET=%HOST_TARGET%"
IF DEFINED ARBIT_FLAG CALL:DISK_DETECT>NUL 2>&1
IF NOT DEFINED ARBIT_FLAG SET "QUERY_X=1"&&CALL:DISK_DETECT
SET "DISK_X=%DISK_DETECT%"&&SET "PART_X=2"&&CALL:PART_8000&&SET "DISK_X=%DISK_DETECT%"&&SET "PART_X=2"&&SET "LETT_X=Z"&&CALL:PART_ASSIGN
IF EXIST "Z:\" IF NOT EXIST "Z:\%HOST_FOLDERX%" MD "Z:\%HOST_FOLDERX%">NUL 2>&1
IF EXIST "Z:\%HOST_FOLDERX%" IF NOT EXIST "Z:\%HOST_FOLDERX%\%PROG_NAME%.cmd" COPY /Y "%PROG_FOLDER%\%PROG_NAME%.cmd" "Z:\%HOST_FOLDERX%">NUL 2>&1
IF EXIST "Z:\%HOST_FOLDERX%\settings.ini" COPY /Y "Z:\%HOST_FOLDERX%\settings.ini" "%PROG_FOLDER%">NUL 2>&1
IF NOT EXIST "Z:\%HOST_FOLDERX%" IF NOT DEFINED ARBIT_FLAG SET "ARBIT_FLAG=1"&&GOTO:HOST_AUTO
SET "ARBIT_FLAG="&&IF EXIST "Z:\%HOST_FOLDERX%" SET "PROG_SOURCE=Z:\%HOST_FOLDERX%"&&SET "HOST_NUMBER=%DISK_DETECT%"
IF NOT DEFINED DISK_DETECT SET "HOST_ERROR=1"&&SET "DISK_TARGET="
EXIT /B
:EFI_MOUNT
IF NOT DEFINED DISK_TARGET SET "EFI_LETTER="&&EXIT /B
SET "$GET=EFI_LETTER"&&CALL:LETTER_ANY
SET /P HOST_TARGET=<"%PROG_FOLDER%\HOST_TARGET"
SET "DISK_TARGET=%HOST_TARGET%"&&CALL:DISK_DETECT>NUL 2>&1
IF NOT DEFINED DISK_DETECT SET "ERROR=1"&&ECHO. %XLR2%ERROR:%#$% EFI target disk could not be found.&&SET "EFI_LETTER="&&EXIT /B
SET "DISK_X=%DISK_DETECT%"&&SET "PART_X=1"&&CALL:PART_BAS
SET "DISK_X=%DISK_DETECT%"&&SET "PART_X=1"&&SET "LETT_X=%EFI_LETTER%"&&CALL:PART_ASSIGN
IF NOT EXIST "%EFI_LETTER%:\" SET "ERROR=1"&&ECHO. %XLR2%ERROR:%#$% EFI %EFI_LETTER%:\ could not be mounted.&&SET "EFI_LETTER="
EXIT /B
:EFI_UNMOUNT
IF NOT DEFINED DISK_TARGET SET "EFI_LETTER="
IF NOT EXIST "%EFI_LETTER%:\" SET "EFI_LETTER="
IF NOT DEFINED EFI_LETTER EXIT /B
SET "DISK_X=%DISK_DETECT%"&&SET "PART_X=1"&&SET "LETT_X=%EFI_LETTER%"&&CALL:PART_REMOVE
SET "DISK_X=%DISK_DETECT%"&&SET "PART_X=1"&&CALL:PART_EFIX
IF EXIST "%EFI_LETTER%:\" SET "ERROR=1"&&ECHO. %XLR2%ERROR:%#$% EFI %EFI_LETTER%:\ could not dismount.
SET "EFI_LETTER="&&EXIT /B
:DISK_MENU
CLS&&SET "ERROR="&&SET "DISK_TARGET="&&CALL:PAD_LINE&&SET "DISK_GET=1"&&CALL:DISK_LIST
CALL:PAD_LINE&&CALL:PAD_PREV&&SET "PROMPT_SET=DISK_NUMBER"&&CALL:PROMPT_SET
SET "CHECK=NUM"&&SET "CHECK_VAR=%DISK_NUMBER%"&&CALL:CHECK&&IF NOT DEFINED DISK_%DISK_NUMBER% SET "ERROR=1"
IF DEFINED ERROR EXIT /B
CALL SET "DISK_TARGET=%%DISKID_%DISK_NUMBER%%%"&&CALL:DISK_DETECT>NUL 2>&1
FOR %%G in (DISK_NUMBER DISK_TARGET) DO (IF NOT DEFINED %%G SET "ERROR=1")
IF "%PROG_MODE%"=="RAMDISK" IF "%HOST_NUMBER%"=="%DISK_NUMBER%" SET "ERROR=1"
IF "%PROG_MODE%"=="RAMDISK" IF "%HOST_TARGET%"=="%DISK_TARGET%" SET "ERROR=1"
EXIT /B
:DISK_LIST
CALL:BOXT1
IF DEFINED QUERY_MSG ECHO.%QUERY_MSG%
(ECHO.LIST DISK&&ECHO.Exit)>"$DSK"&&FOR /F "TOKENS=1-5 SKIP=8 DELIMS= " %%a in ('DISKPART /s "$DSK"') DO (
IF "%%a"=="Disk" IF NOT "%%b"=="###" SET "DISKVND="&&(ECHO.select disk %%b&&ECHO.detail disk&&ECHO.list partition&&ECHO.Exit)>"$DSK"&&SET "LTRX=X"&&FOR /F "TOKENS=1-9 SKIP=6 DELIMS={}: " %%1 in ('DISKPART /s "$DSK"') DO (
IF "%%1 %%2"=="Disk %%b" ECHO.&&ECHO. %#@%Disk%#$% ^(%##%%%b%#$%^)
IF NOT "%%1 %%2"=="Disk %%b" IF NOT DEFINED DISKVND SET "DISKVND=$"&&ECHO. %%1 %%2 %%3 %%4 %%5
IF "%%1"=="Type" ECHO. %#@%Type%#$% = %%2
IF "%%1 %%2"=="Disk ID" ECHO. %#@%UID%#$% = %%3
IF "%%1 %%2 %%3"=="Pagefile Disk Yes" ECHO. %XLR2% Active Pagefile%#$%
IF "%%1"=="Partition" IF NOT "%%2"=="###" SET "PARTX=%%2"&&SET "SIZEX=%%4 %%5"&&(ECHO.select disk %%b&&ECHO.select partition %%2&&ECHO.detail partition&&ECHO.Exit)>"$DSK"&&SET "LTRX="&&FOR /F "TOKENS=1-9 SKIP=6 DELIMS=* " %%A in ('DISKPART /s "$DSK"') DO (IF "%%A"=="Volume" IF NOT "%%B"=="###" SET "LTRX=%%C"&&CALL:DISK_CHECK)
IF NOT DEFINED LTRX IF NOT "%%2"=="DiskPart..." ECHO. %#@%Part %%2%#$% Vol * %%4 %%5))
IF DEFINED DISK_GET CALL:DISK_DETECT>NUL 2>&1
ECHO.&&CALL:BOXB1
FOR %%a in (PASS LTRX PARTX SIZEX QUERY_MSG DISK_GET) DO (SET "%%a=")
DEL /Q /F "$DSK*">NUL 2>&1
EXIT /B
:DISK_CHECK
SET "PASS="&&FOR %%$ in (A B 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 "%%$"=="%LTRX%" SET "PASS=1"&&ECHO. %#@%Part %PARTX%%#$% Vol %#@%%LTRX%%#$% %SIZEX%)
IF NOT DEFINED PASS ECHO. %#@%Part %PARTX%%#$% Vol * %SIZEX%
EXIT /B
:DISK_DETECT
FOR /F "TOKENS=1 DELIMS=:" %%G in ("%SystemDrive%") DO (SET "SYS_VOLUME=%%G")
FOR /F "TOKENS=1 DELIMS=:" %%G in ("%PROG_SOURCE%") DO (SET "PROG_VOLUME=%%G")
SET "DISK_DETECT="&&FOR %%a in (0 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) DO (IF DEFINED DISK_%%a SET "DISK_%%a="&&SET "DISKID_%%a=")
(ECHO.LIST DISK&&ECHO.Exit)>"$DSK"&&FOR /F "TOKENS=1,2,4 SKIP=8 DELIMS= " %%a in ('DISKPART /s "$DSK"') DO (IF "%%a"=="Disk" IF NOT "%%b"=="###" SET "DISK_%%b="&&(ECHO.select disk %%b&&ECHO.detail disk&&ECHO.list partition&&ECHO.Exit)>"$DSK"&&FOR /F "TOKENS=1-9 SKIP=6 DELIMS={}: " %%1 in ('DISKPART /s "$DSK"') DO (
IF "%%1 %%2"=="Disk %%b" SET "DISK_%%b=%%b"
IF "%%1 %%2"=="Disk ID" SET "DISKID_%%b=%%3"&&IF "%%3"=="%DISK_TARGET%" SET "DISK_DETECT=%%b"
IF "%%1 %%2"=="Disk ID" IF DEFINED QUERY_X ECHO. Getting info for disk uid %##%%%3%#$%...
IF "%%1 %%2 %%3"=="Pagefile Disk Yes" SET "DISK_%%b="
IF "%%2 %%3 %%4"=="File Backed Virtual" SET "DISK_%%b=VDISK"
IF "%%1 %%3"=="Volume %SYS_VOLUME%" SET "DISK_%%b="
IF "%%1 %%3"=="Volume %PROG_VOLUME%" SET "DISK_%%b="
IF "%%1 %%3"=="Volume Z" IF "%PROG_MODE%"=="RAMDISK" SET "HOST_VOLUME=%%2"))
IF DEFINED QUERY_X SET "QUERY_X="&&CLS
DEL /Q /F "$DSK*">NUL 2>&1
EXIT /B
:PART_EFI1
FOR %%a in (DISK_X) DO (IF NOT DEFINED %%a EXIT /B)
IF NOT DEFINED SIZE_X SET "SIZE_X=1024"
(ECHO.select disk %DISK_X%&&ECHO.create partition EFI size=%SIZE_X%&&ECHO.format quick fs=fat32 label="ESP"&&ECHO.Exit)>"$DSK"&&DISKPART /s "$DSK">NUL 2>&1
SET "PART_X=1"&&SET "LETT_X=%EFI_LETTER%"&&CALL:PART_ASSIGN
IF NOT EXIST "%EFI_LETTER%:\" SET "EFI=2"
SET "DISK_X="&&SET "PART_X="&&SET "LETT_X="&&SET "SIZE_X="&&CALL:DEL_DSK&&EXIT /B
:PART_EFI2
FOR %%a in (DISK_X) DO (IF NOT DEFINED %%a EXIT /B)
IF NOT DEFINED SIZE_X SET "SIZE_X=1024"
(ECHO.select disk %DISK_X%&&ECHO.create partition primary size=%SIZE_X%&&ECHO.format quick fs=fat32 label="ESP"&&ECHO.Exit)>"$DSK"&&DISKPART /s "$DSK">NUL 2>&1
SET "PART_X=1"&&SET "LETT_X=%EFI_LETTER%"&&CALL:PART_ASSIGN
SET "DISK_X="&&SET "PART_X="&&SET "LETT_X="&&SET "SIZE_X="&&CALL:DEL_DSK&&EXIT /B
:PART_CREATE
SET "SIZE_X="&&IF NOT DEFINED EFI SET "EFI=1"
IF "%EFI%"=="1" CALL:DISKMGR_ERASE&&SET "DISK_X=%DISK_NUMBER%"&&CALL:PART_EFI1
IF "%EFI%"=="2" CALL:DISKMGR_ERASE&&SET "DISK_X=%DISK_NUMBER%"&&CALL:PART_EFI2
IF EXIST "%EFI_LETTER%:\" (IF DEFINED HOST_SIZE SET "CHECK_VAR=%HOST_SIZE%"&&SET "CHECK=NUM"&&CALL:CHECK>NUL 2>&1
IF DEFINED HOST_SIZE IF DEFINED ERROR SET "ERROR="&&IF NOT DEFINED RETRY_PART1 IF NOT DEFINED RETRY_PART2 IF NOT DEFINED RETRY_PART3 ECHO. %XLR4%ERROR:%#$% Invalid host partition size, using available free space.&&SET "HOST_SIZE="
IF DEFINED HOST_SIZE SET "SIZE_X=%HOST_SIZE%"
SET "DISK_X=%DISK_NUMBER%"&&CALL:PART_PRIMARY
SET "DISK_X=%DISK_NUMBER%"&&SET "PART_X=2"&&SET "LETT_X=%PRI_LETTER%"&&CALL:PART_ASSIGN
IF DEFINED HOST_SIZE IF EXIST "%PRI_LETTER%:\" SET "DISK_X=%DISK_NUMBER%"&&CALL:PART_PRIMARY
IF DEFINED HOST_SIZE IF EXIST "%PRI_LETTER%:\" SET "DISK_X=%DISK_NUMBER%"&&SET "PART_X=3"&&SET "LETT_X=%TST_LETTER%"&&CALL:PART_ASSIGN)
IF EXIST "%EFI_LETTER%:\" IF EXIST "%PRI_LETTER%:\" SET "RETRY_PART1="&&SET "RETRY_PART2="&&SET "RETRY_PART3="&&SET "EFI="&&EXIT /B
FOR %%a in (1 2 3) DO (IF NOT DEFINED RETRY_PART%%a SET "RETRY_PART%%a=1"&&SET "EFI="&&GOTO:PART_CREATE)
ECHO. %XLR2%The disk is currently in use.%#$%&&ECHO. A malfunctioning disk, or if a program located on the disk&&ECHO. is currently in use can also cause an error.&&ECHO. For best results it is recommended to use an external nvme drive.&&ECHO. Unplug the USB disk and/or reboot if this continues to occur.&&ECHO.
SET "RETRY_PART1="&&SET "RETRY_PART2="&&SET "RETRY_PART3="&&SET "EFI="&&ECHO.&&SET "ERROR=1"&&EXIT /B
::#########################################################################
:BOOT_CREATOR_START
::#########################################################################
SET "PROG_NAME=deploid"&&CLS&&CALL:BOXT2&&ECHO. %#@%BOOT CREATOR START:%#$% %DATE% %TIME%&&ECHO.
SET "DISK_MSG="&&DISM /cleanup-MountPoints>NUL 2>&1
SET "CHAR_STR=%VHDX_SLOTX%"&&SET "CHAR_CHK= "&&CALL:CHAR_CHK
IF DEFINED CHAR_FLG SET "ERROR=1"&&ECHO. %XLR4%ERROR:%#$% Remove the space from the VHDX name, then try again.&&GOTO:BOOT_FINISH
SET "UID_XNT="&&FOR /F "DELIMS=" %%G in ('CMD.EXE /D /U /C ECHO.%DISK_TARGET%^| FIND /V ""') do (CALL SET /A "UID_XNT+=1")
IF NOT "%UID_XNT%"=="36" (ECHO. Converting to GPT..&&CALL:DISKMGR_ERASE&&CALL:DISK_DETECT>NUL 2>&1
SET "DISK_TARGET="&&FOR %%a in (0 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) DO (IF "%DISK_NUMBER%"=="%%a" CALL SET "DISK_TARGET=%%DISKID_%%a%%"&&CALL ECHO. Assigning new disk uid %%DISKID_%%a%%...&&CALL:DISK_DETECT>NUL 2>&1))
SET "UID_XNT="&&FOR /F "DELIMS=" %%G in ('CMD.EXE /D /U /C ECHO.%DISK_TARGET%^| FIND /V ""') do (CALL SET /A "UID_XNT+=1")
IF NOT "%UID_XNT%"=="36" ECHO. %XLR2%ERROR:%#$% Disk could not be converted to GPT.&&GOTO:BOOT_FINISH
FOR %%a in (DISK_DETECT DISK_NUMBER DISK_TARGET) DO (IF NOT DEFINED %%a ECHO. %XLR2%ERROR:%#$% Unable to query disk number or uid.&&GOTO:BOOT_FINISH)
SET "EFI_LETTER="&&FOR %%G in (Z Y X W V U T S R Q P O N M L K J I H G F E D) DO (IF NOT EXIST "%%G:\" SET "EFI_LETTER=%%G")
SET "PRI_LETTER="&&FOR %%G in (Z Y X W V U T S R Q P O N M L K J I H G F E D) DO (IF NOT EXIST "%%G:\" IF NOT "%%G"=="%EFI_LETTER%" SET "PRI_LETTER=%%G")
SET "TST_LETTER="&&FOR %%G in (Z Y X W V U T S R Q P O N M L K J I H G F E D) DO (IF NOT EXIST "%%G:\" IF NOT "%%G"=="%EFI_LETTER%" IF NOT "%%G"=="%PRI_LETTER%" SET "TST_LETTER=%%G")
ECHO. Creating partitions on disk uid %DISK_TARGET%...&&CALL:PART_CREATE
IF DEFINED ERROR GOTO:BOOT_CLEANUP
ECHO. Mounting temporary vdisk...&&MD "%PRI_LETTER%:\%HOST_FOLDER%\scratch">NUL 2>&1
FOR %%a in (%PRI_LETTER%: %PRI_LETTER%:\%HOST_FOLDER%) DO (ICACLS "%%a" /deny everyone:^(DE,WA,WDAC^)>NUL 2>&1)
SET "VDISK=%PRI_LETTER%:\%HOST_FOLDER%\scratch\scratch.vhdx"&&SET "VDISK_LTR=ANY"&&CALL:VDISK_CREATE>NUL 2>&1
IF EXIST "%BOOT_FOLDER%\BOOT.SAV" ECHO. Extracting boot-media. Using boot.sav located in folder...&© /Y "%BOOT_FOLDER%\boot.sav" "%PRI_LETTER%:\%HOST_FOLDER%\boot.wim">NUL 2>&1
SET "IMAGEFILE=%PRI_LETTER%:\%HOST_FOLDER%\boot.wim"&&SET "INDEX_WORD=Setup"&&CALL:FIND_INDEX
SET "IMAGEFILE=%PRI_LETTER%:\%HOST_FOLDER%\boot.wim"&&SET "APPLYDIR=%VDISK_LTR%:"&&IF NOT DEFINED IMAGEINDEX SET "IMAGEINDEX=1"
DISM /ENGLISH /APPLY-IMAGE /IMAGEFILE:"%IMAGEFILE%" /INDEX:%IMAGEINDEX% /APPLYDIR:"%APPLYDIR%"&ECHO.
MOVE /Y "%PRI_LETTER%:\%HOST_FOLDER%\boot.wim" "%PRI_LETTER%:\%HOST_FOLDER%\boot.sav">NUL 2>&1
IF NOT EXIST "%VDISK_LTR%:\Windows" SET "ERROR=1"&&ECHO. %XLR2%ERROR:%#$% Mount failure, Index %IMAGEINDEX% &&GOTO:BOOT_CLEANUP
MD "%APPLYDIR%\$">NUL 2>&1
ECHO.%DISK_TARGET%>"%APPLYDIR%\$\HOST_TARGET"
ECHO.%HOST_FOLDER%>"%APPLYDIR%\$\HOST_FOLDER"
COPY /Y "%PROG_SOURCE%\%PROG_NAME%.cmd" "%APPLYDIR%\$">NUL© /Y "%PROG_SOURCE%\%PROG_NAME%.cmd" "%PRI_LETTER%:\%HOST_FOLDER%">NUL© /Y "%PROG_SOURCE%\settings.ini" "%PRI_LETTER%:\%HOST_FOLDER%">NUL
FOR %%a in (Boot EFI\Boot EFI\Microsoft\Boot) DO (MD %EFI_LETTER%:\%%a>NUL 2>&1)
IF EXIST "%BOOT_FOLDER%\boot.sdi" ECHO. Using boot.sdi located in folder, for efi image boot support.&© /Y "%BOOT_FOLDER%\boot.sdi" "%EFI_LETTER%:\Boot">NUL
IF NOT EXIST "%BOOT_FOLDER%\boot.sdi" COPY /Y "%APPLYDIR%\Windows\Boot\DVD\EFI\boot.sdi" "%EFI_LETTER%:\Boot">NUL 2>&1
IF NOT EXIST "%EFI_LETTER%:\Boot\boot.sdi" SET "ERROR=1"&&ECHO. %XLR2%ERROR:%#$% boot.sdi missing.&&GOTO:BOOT_CLEANUP
IF EXIST "%BOOT_FOLDER%\bootmgfw.efi" ECHO. Using bootmgfw.efi located in folder, for the efi bootloader.&© /Y "%BOOT_FOLDER%\bootmgfw.efi" "%EFI_LETTER%:\EFI\Boot\bootx64.efi">NUL
IF NOT EXIST "%BOOT_FOLDER%\bootmgfw.efi" COPY /Y "%APPLYDIR%\Windows\Boot\EFI\bootmgfw.efi" "%EFI_LETTER%:\EFI\Boot\bootx64.efi">NUL 2>&1
IF NOT EXIST "%EFI_LETTER%:\EFI\Boot\bootx64.efi" SET "ERROR=1"&&ECHO. %XLR2%ERROR:%#$% bootmgfw.efi missing.&&GOTO:BOOT_CLEANUP
IF DEFINED PE_WALLPAPER IF EXIST "%CACHE_FOLDER%\%PE_WALLPAPER%" (ECHO. Using %PE_WALLPAPER% for the recovery wallpaper.
TAKEOWN /F "%APPLYDIR%\Windows\System32\setup.bmp">NUL 2>&1
ICACLS "%APPLYDIR%\Windows\System32\setup.bmp" /grant %USERNAME%:F>NUL 2>&1
COPY /Y "%CACHE_FOLDER%\%PE_WALLPAPER%" "%APPLYDIR%\Windows\System32\setup.bmp">NUL 2>&1)
IF EXIST "%APPLYDIR%\setup.exe" DEL /Q /F "\\?\%APPLYDIR%\setup.exe">NUL 2>&1
COPY /Y "%APPLYDIR%\Windows\System32\config\ELAM" "%TEMP%\BCD">NUL 2>&1
::ECHO."%%SYSTEMDRIVE%%\$\%PROG_NAME%.CMD">"%APPLYDIR%\WINDOWS\SYSTEM32\STARTNET.CMD"
(ECHO.[LaunchApp]&&ECHO.AppPath=X:\$\%PROG_NAME%.cmd)>"%APPLYDIR%\Windows\System32\winpeshl.ini"
SET "VHDX_SLOTZ=%VHDX_SLOT0%"&&SET "VHDX_SLOT0=%VHDX_SLOTX%"&&SET "HOST_X=%HOST_FOLDER%"&&CALL:BCD_CREATE>NUL 2>&1
SET "VHDX_SLOT0=%VHDX_SLOTZ%"&&SET "VHDX_SLOTZ="&&IF NOT EXIST "%EFI_LETTER%:\EFI\Microsoft\Boot\BCD" SET "ERROR=1"&&ECHO. %XLR2%ERROR:%#$% BCD missing.&&GOTO:BOOT_CLEANUP
::DISM /IMAGE:"%APPLYDIR%" /SET-SCRATCHSPACE:512 >NUL 2>&1
ECHO. Saving boot-media...&&SET "IMAGEFILE=%EFI_LETTER%:\$.WIM"&&SET "CAPTUREDIR=%VDISK_LTR%:"
DISM /ENGLISH /CAPTURE-IMAGE /IMAGEFILE:"%IMAGEFILE%" /CAPTUREDIR:"%CAPTUREDIR%" /NAME:NAME /CheckIntegrity /Verify /Bootable&ECHO.&SET "IMAGEFILE="
:BOOT_CLEANUP
ECHO. Unmounting temporary vdisk...&&SET "VDISK=%PRI_LETTER%:\%HOST_FOLDER%\scratch\scratch.vhdx"&&CALL:VDISK_DETACH>NUL 2>&1
ECHO. Unmounting EFI...&&IF EXIST "%PRI_LETTER%:\%HOST_FOLDER%\scratch" RD /S /Q "%PRI_LETTER%:\%HOST_FOLDER%\scratch">NUL 2>&1
SET "DISK_X=%DISK_DETECT%"&&SET "PART_X=1"&&SET "LETT_X=%EFI_LETTER%"&&CALL:PART_REMOVE
SET "DISK_X=%DISK_DETECT%"&&SET "PART_X=1"&&CALL:PART_EFIX
IF NOT DEFINED ERROR (IF DEFINED VHDX_SLOTX IF EXIST "%IMAGE_FOLDER%\%VHDX_SLOTX%" IF EXIST "%PRI_LETTER%:\%HOST_FOLDER%" ECHO. Copying %VHDX_SLOTX%...&© /Y "%IMAGE_FOLDER%\%VHDX_SLOTX%" "%PRI_LETTER%:\%HOST_FOLDER%">NUL 2>&1
FOR %%a in (1 2 3 4 5) DO (CALL SET "ADDFILE_CHK=%%ADDFILE_%%a%%"&&CALL:ADDFILE_COPY))
:BOOT_FINISH
SET "IMAGEFILE="&&SET "IMAGEINDEX="&&SET "EFI_LETTER="&&SET "PRI_LETTER="&&SET "TST_LETTER="&&IF "%PROG_MODE%"=="RAMDISK" CALL:HOST_AUTO>NUL 2>&1
CALL:DEL_DSK&&ECHO.&&ECHO. %#@%BOOT CREATOR END:%#$% %DATE% %TIME%&&CALL:BOXB2
EXIT /B
:FIND_INDEX
IF NOT DEFINED IMAGEFILE EXIT /B
SET "IMAGEINDEX="&&CALL SET /A "INDEX_XNT+=1"
FOR /F "TOKENS=5 SKIP=5 DELIMS=<> " %%a in ('DISM /ENGLISH /GET-IMAGEINFO /IMAGEFILE:"%IMAGEFILE%" /INDEX:%INDEX_XNT% 2^>NUL') DO (IF "%%a"=="%INDEX_WORD%" SET "IMAGEINDEX=%INDEX_XNT%"&&GOTO:FIND_INDEX_BREAK)
IF NOT DEFINED IMAGEINDEX IF NOT "%INDEX_XNT%" EQU "20" GOTO:FIND_INDEX
:FIND_INDEX_BREAK
SET "IMAGEFILE="&&SET "INDEX_XNT="&&SET "INDEX_WORD="
EXIT /B
:ADDFILE_COPY
IF NOT DEFINED ADDFILE_CHK EXIT /B
IF "%ADDFILE_CHK%"=="SELECT" EXIT /B
IF EXIST "%PROG_SOURCE%\%ADDFILE_CHK%" IF NOT EXIST "%PROG_SOURCE%\%ADDFILE_CHK%\*" ECHO. Copying %ADDFILE_CHK%...&© /Y "%PROG_SOURCE%\%ADDFILE_CHK%" "%PRI_LETTER%:\%HOST_FOLDER%">NUL 2>&1
EXIT /B
:BCD_MENU
CLS&&CALL:SETS_HANDLER&&CALL:CLEAN&&CALL:PAD_LINE&&CALL:BOXT1&&IF NOT DEFINED BOOT_TIMEOUT SET "BOOT_TIMEOUT=5"
ECHO. Boot Menu Editor&&ECHO.&&ECHO. Time (%##%T%#$%^) %#@%%BOOT_TIMEOUT%%#$% seconds
FOR %%G in (0 1 2 3 4 5 6 7 8 9) DO (CALL ECHO. Slot ^(%##%%%G%#$%^) %#@%%%VHDX_SLOT%%G%%%#$%)
ECHO.&&ECHO. Press (%##%X%#$%) to apply boot menu settings&&CALL:BOXB1&&CALL:PAD_LINE&&CALL:PAD_PREV&&CALL:MENU_SELECT
IF NOT DEFINED SELECT EXIT /B
IF "%SELECT%"=="T" CALL:BOOT_TIMEOUT&SET "SELECT="
IF "%SELECT%"=="X" IF "%PROG_MODE%"=="RAMDISK" CALL:BCD_REBUILD&SET "SELECT="
FOR %%G in (0 1 2 3 4 5 6 7 8 9) DO (IF "%SELECT%"=="%%G" SET "$VHDX=%%G"&&CALL:VHDX_CHECK&SET "SELECT=")
GOTO:BCD_MENU
:BOOT_TIMEOUT
CALL:PAD_LINE&&CALL:BOXT1&&ECHO.&&ECHO. Enter boot menu timeout in seconds&&ECHO.&&CALL:BOXB1&&CALL:PAD_LINE&&CALL:PAD_PREV&&CALL:MENU_SELECT
SET "CHECK=NUM"&&SET "CHECK_VAR=%SELECT%"&&CALL:CHECK
IF NOT DEFINED ERROR SET "BOOT_TIMEOUT=%SELECT%"
IF DEFINED ERROR SET "BOOT_TIMEOUT="
EXIT /B
:VHDX_CHECK
CLS&&IF "%$VHDX%"=="X" SET "MENUT0= Boot Creator"&&SET "MENUT1= "&&SET "MENUT2= %#@%AVAILABLE VHDXs:%#$%"&&SET "MENUT3= "&&SET "MENUT4= ( %##%.%#$% ) File Operation"&&SET "MENUB0= "&&SET "PICK=VHDX"&&CALL:FILE_PICK
IF "%$VHDX%"=="X" IF "%SELECT%"=="." SET "FILE_TYPE=VHDX"&&CALL:BASIC_FILE&SET "ERROR=1"&EXIT /B
IF NOT "%$VHDX%"=="X" SET "MENUT0= Boot Menu Editor"&&SET "MENUT1= "&&SET "MENUT2= %#@%MAIN FOLDER VHDXs:%#$%"&&SET "MENUT3= "&&SET "MENUT4= ( %##%.%#$% ) File Operation"&&SET "MENUB0= "&&SET "PICK=CUST"&&SET "$FOLD0=%PROG_SOURCE%"&&SET "$FILT0=*.VHDX"&&CALL:FILE_PICK
IF NOT "%$VHDX%"=="X" IF "%SELECT%"=="." SET "FILE_TYPE=MAIN"&&CALL:BASIC_FILE&SET "ERROR=1"&EXIT /B
IF NOT DEFINED $PICK SET "VHDX_SLOT%$VHDX%="&&SET "$VHDX="&&EXIT /B
SET "CHAR_STR=%$TRUMP%"&&SET "CHAR_CHK= "&&CALL:CHAR_CHK
IF DEFINED CHAR_FLG CALL:PAD_LINE&&CALL:BOXT1&&ECHO.&&ECHO. Remove the space from the VHDX name, then try again.&&ECHO.&&CALL:BOXB1&&CALL:PAD_LINE&&SET "VHDX_SLOT%$VHDX%="&&CALL:PAUSED
IF NOT DEFINED CHAR_FLG SET "VHDX_SLOT%$VHDX%=%$TRUMP%"
SET "$VHDX="
EXIT /B
:BCD_CREATE
IF NOT DEFINED BOOT_TIMEOUT SET "BOOT_TIMEOUT=5"
SET "BCD_KEY=BCD00000001"&&SET "BCD_FILE=%TEMP%\$BCD"
FOR %%a in (BCD BCD1 $BCD) DO (IF EXIST "%TEMP%\%%a" DEL /Q /F "%TEMP%\%%a" >NUL)
BCDEDIT.EXE /createstore "%BCD_FILE%"
BCDEDIT.EXE /STORE "%BCD_FILE%" /create {bootmgr}
BCDEDIT.EXE /STORE "%BCD_FILE%" /SET {bootmgr} description "Boot Manager"
BCDEDIT.EXE /STORE "%BCD_FILE%" /SET {bootmgr} device boot
BCDEDIT.EXE /STORE "%BCD_FILE%" /SET {bootmgr} timeout %BOOT_TIMEOUT%
FOR /f "TOKENS=2 DELIMS={}" %%a in ('BCDEDIT.EXE /STORE "%BCD_FILE%" /create /device') do SET "RAMDISK={%%a}"