-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathMultiboot-Toolkit.bat
3196 lines (2880 loc) · 112 KB
/
Multiboot-Toolkit.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
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
@echo off
:: https://niemtin007.blogspot.com
:: The batch file is written by niemtin007.
:: Thank you for using Multiboot Toolkit.
cd /d "%~dp0"
set "bindir=%~dp0bin"
call :get.config Version version
if not exist Modules mkdir Modules
if not exist "bin" (
call :printMissing
) else (
call :permissions
call :license
)
:mainMenu
call :colortool "Menu"
echo.
call :printc " ___ _____ _____ _____ _____ _____ _____ _____ _____ _ _ _ "
call :printc "|_ | | | __ | __| _ |_ _| __| | | | __| | | | "
call :printc " _| |_ _ | --| -| __| | | | | __| | | | | __| | | | "
call :printc "|_____|_| |_____|__|__|_____|__|__| |_| |_____| |_|___|_____|_____| "
echo.
call :printc " ___ _____ ____ ____ _____ _____ ____ _____ __ _____ _____ "
call :printc "|_ | | _ | \| \ | | | \| | | | | __| __|"
call :printc "| _|_ | | | | | | | | | | | | | | | | |__| __|__ |"
call :printc "|___|_| |__|__|____/|____/ |_|_|_|_____|____/|_____|_____|_____|_____|"
echo.
call :printc " ___ _____ _____ _____ _____ _____ _____ _____ _____ _____ "
call :printc "|_ | | | | | __|_ _| | | |__ | __| "
call :printc "|_ |_ | --| | |__ | | | | | | | | |- -| __| __| "
call :printc "|___|_| |_____|_____|_____| |_| |_____|_|_|_|_____|_____|_____| "
echo.
call :printc "========================================================================="
call :printj "[ 1 ]" "%_lang0017_%"
call :printj "[ 2 ]" "%_lang0018_%"
call :printj "[ 3 ]" "%_lang0019_%"
call :printc "========================================================================="
echo.
choice /c 1234q /cs /n /m "%_symbol_%%spaces%%_lang0020_%"
if errorlevel 5 call :license
if errorlevel 4 timeout /t 1 >nul & goto :qemuboottester
if errorlevel 3 timeout /t 1 >nul & goto :extraFeatures
if errorlevel 2 timeout /t 1 >nul & goto :moduleInstaller
if errorlevel 1 timeout /t 1 >nul & goto :bootableCreator
:: =========================================
:: INSTALL MULTIBOOT
:: =========================================
:bootableCreator
call :colortool "Bootable Creator"
call :list.disk
echo.
choice /c 01234567q /cs /n /m "%_lang0101_%"
if errorlevel 1 set /a disk = 0
if errorlevel 2 set /a disk = 1
if errorlevel 3 set /a disk = 2
if errorlevel 4 set /a disk = 3
if errorlevel 5 set /a disk = 4
if errorlevel 6 set /a disk = 5
if errorlevel 7 set /a disk = 6
if errorlevel 8 set /a disk = 7
if errorlevel 9 goto :mainMenu
call :checkdisktype
if "%virtualdisk%"=="true" call :rEFInd.part & goto :External
if "%harddisk%"=="true" call :harddisk.warning & goto :bootableCreator
if "%usb%"=="true" call :rEFInd.part & goto :removable
if "%externaldisk%"=="true" call :rEFInd.part & goto :External
color 0e & echo. & echo %_lang0104_% & timeout /t 15 >nul & goto :bootableCreator
:removable
call :colortool
:: prepare partitions space for removable Media
echo.
echo %_symbol_%%spaces%%_lang0128_%
call :clean.disk
call :clean.disk
call :get.freeDrive
:: create rEFInd partition
call :colortool
partassist /hd:%disk% /cre /pri /size:%esp% /end /fs:fat32 /align /label:%ESP1% /letter:%freedrive%
call :unhide.partition 0
call :pushdata.rEFInd
mountvol %freedrive%: /d
if "%secureboot%"=="n" goto :usbmultibootdata
:: create ESP partition
call :colortool
partassist /hd:%disk% /cre /pri /size:50 /fs:fat32 /label:%ESP2% /letter:%freedrive%
partassist /move:%freedrive% /right:auto /align
call :unhide.partition 0
call :pushdata.ESP
mountvol %freedrive%: /d
:usbmultibootdata
:: create Multiboot data partition
call :colortool
call :create.mpart
call :unhide.partition 0
goto :extractdata
:External
call :scan.label %DATA%
:: prepare partitions space for External hard disk media
call :count.partition
:: the disk is an unallocated
if not defined partcount goto :Setup
:: set multiboot data partition size
echo.
set /a GB=0
set /p GB=%_symbol_%%spaces%%_lang0106_%
set /a GB=%GB%+0
:: check the character of the number
echo %esp%| findstr /r "^[1-9][0-9]*$">nul
if not "%errorlevel%"=="0" goto :External
:: sum size of the esp partition
set /a MB=(%GB%*1024+%esp%)
:: check the installed status and give instruction
if "%online%"=="true" if "%disk%"=="%diskscan%" (
echo. & echo ^>%spaces%%_lang0107_% & timeout /t 300 >nul
goto :delete
)
if "%online%"=="false" if "%GB%"=="0" (
call :colortool
echo. & echo ^>%spaces%%_lang0108_% & timeout /t 15 >nul
goto :External
)
goto :continue
:delete
call :colortool
call :count.partition
if not defined partcount goto :Setup
:: delete all multiboot partition without data loss
partassist /hd:%disk% /unhide:0
call :get.freeDrive
partassist /hd:%disk% /setletter:0 /letter:%freedrive%
call :check.author %freedrive%:
:: this code not perfect
:: {case-1} if a partition file system isn't windows type may be deleted
:: {case-2} data will lose if the user copied the EFI folder into a
:: data partition with the same Multiboot's drive label
if "%installed%"=="true" if "%disk%"=="%diskscan%" (
partassist /hd:%disk% /del:0
goto :delete
)
:continue
call :fix.filesystem
partassist /hd:%disk% /setletter:0 /letter:auto
:: only resize partition for new size setting or new installing
if "%online%"=="true" if not "%GB%"=="0" (
partassist /hd:%disk% /resize:0 /reduce-left:%MB% /align
)
if "%online%"=="false" (
partassist /hd:%disk% /resize:0 /reduce-left:%MB% /align
)
:Setup
call :get.freeDrive
call :set.partnum esp2 esp1
:esp1
:: Create ESP Partition
call :colortool
call :create.epart
call :unhide.partition 0
call :pushdata.ESP
mountvol %freedrive%: /d
:esp2
:: Create rEFInd partition
call :colortool
call :create.rpart
call :unhide.partition %rpart%
call :pushdata.rEFInd
mountvol %freedrive%: /d
:: Create Multiboot Data Partition
call :colortool
call :check.diskInfo
if "%GPT%"=="true" (
partassist /hd:%disk% /cre /pri /size:auto /offset:%offset% /fs:ntfs /act /align /label:%DATA% /letter:%freedrive%
) else (
partassist /hd:%disk% /cre /pri /size:auto /fs:ntfs /act /align /label:%DATA% /letter:%freedrive%
)
call :unhide.partition %mpart%
:extractdata
call :colortool
call :scan.label %DATA%
if "%ducky%"=="%freedrive%:" (
7z x "data.7z" -o"%ducky%\" -aoa -y
) else (
call :colortool
echo. & echo %_lang0110_% & timeout /t 7 >nul
:: change data partition label to DATA
label %ducky% DATA & goto :extractdata
)
>"%ducky%\EFI\BOOT\mark" (echo niemtin007)
call :configuration
cd /d "%bindir%\config\bcd"
xcopy "B84" "%ducky%\BOOT\bootmgr\" /e /g /h /r /y /q >nul
cd /d "%bindir%\secureboot\BOOT"
xcopy "boot.sdi" "%ducky%\BOOT\" /e /g /h /r /y /q >nul
cd /d "%bindir%"
:: install grub4dos
call :grub4dosinstaller %ducky%
:: install wincdemu to mount iso files
7z x "wincdemu.7z" -o"%ducky%\ISO\" -aoa -y >nul
:: install Syslinux Bootloader
syslinux --force --directory /BOOT/syslinux %ducky% %ducky%\BOOT\syslinux\syslinux.bin
:: install grub2 Bootloader
call :colortool
if "%GPT%"=="true" call :gdisk
echo.
echo %_symbol_%%spaces%%_lang0116_%
call :grub2installer %DATA%
call :install.grubfm
:: install language
echo.
echo %_symbol_%%spaces%%_lang0112_% %lang%
7z x "%bindir%\config\%lang%.7z" -o"%ducky%\" -aoa -y >nul
cd /d "%tmp%\rEfind_themes\%rtheme%\icons"
echo.
echo %_symbol_%%spaces%%_lang0111_% %rtheme%
call :rEFInd.icons %ducky%
echo.
echo %_symbol_%%spaces%%_lang0113_% %gtheme%
call :install.gtheme
cd /d "%bindir%\secureboot\EFI\Microsoft\Boot"
call :bcdautoset bcd
:: install secure boot file
if "%secureboot%"=="n" call :pushdata.secure
if "%secureboot%"=="y" call :get.path epath %ESP2%
if "%secureboot%"=="y" (
cd /d "%bindir%"
call :copy.hidden "secureboot" "%epath%" >nul 2>&1
cd /d "%bindir%\secureboot\EFI\Boot"
xcopy "backup" "%ducky%\EFI\Boot\backup\" /e /g /h /r /y /q >nul
)
:: start modules installer
if "%installmodules%"=="y" call :moduleInstaller
mountvol %ducky% /d
call :check.letter
call :clean.bye
:: =========================================
:: INSTALL MODULES
:: =========================================
:moduleInstaller
set "curpath=%~dp0Modules"
call :colortool "Module Installer"
call :multibootscan
call :gather.info
:modules.main
> "%tmp%\modules.vbs" (
echo Dim Message, Speak
echo Set Speak=CreateObject^("sapi.spvoice"^)
echo Speak.Speak "Please put all modules you need into the Modules folder."
echo Speak.Speak "Then press any key to continue..."
)
:: move module to the source folder
call :moveISO specialiso
call :moveISO isoextract
call :get.freeDrive
if "%installmodules%"=="y" (
call :check.empty
goto :modules.continue
)
call :colortool
echo.
echo ======================================================================
echo %_lang0200_%
echo ^ %curpath%
echo %_lang0201_% %ducky%
echo ======================================================================
if not exist "%ducky%\PortableApps" call :PortableAppsPlatform
echo.
cd /d "%tmp%"
echo %_lang0202_%
call :speechOn modules.vbs
echo %_lang0203_% & timeout /t 300 >nul
call :speechOff modules.vbs
call :check.empty
:modules.continue
cd /d "%bindir%"
if not exist specialiso mkdir specialiso
if not exist isoextract mkdir isoextract
:: create all modules namelist
if not exist "%ducky%\BOOT\namelist\temp" mkdir "%ducky%\BOOT\namelist\temp"
for /f "tokens=*" %%i in ('dir /a:-d /b "%curpath%"') do (
>"%ducky%\BOOT\namelist\temp\%%~ni" (echo %%i)
)
:: rename all modules namelist
cd /d "%bindir%"
for /f "delims=" %%f in (isoextract.list) do (
cd /d "%ducky%\BOOT\namelist\temp"
if exist "*%%f*" ren "*%%f*" "%%f" >nul
cd /d "%bindir%"
)
:: move all iso to temp folder
call :moveISOTemp isoextract
call :moveISOTemp specialiso
:: check iso extract type
call :checkISO isoextract modules.specialiso
cd /d "%bindir%"
7z x "wincdemu.7z" -o"%tmp%" -aoa -y >nul
wincdemu /install
:extract.list
cd /d "%ducky%\BOOT\namelist\temp"
call :iso.extract aomei , AOMEI-Backup
call :iso.extract android , Android-x86
call :iso.extract anhdv , anhdvPE
call :iso.extract Bob.Ombs , Bob.Ombs.Win10PEx64
call :iso.extract bugtraq , Bugtraq
call :iso.extract caine , Caine
call :iso.extract cyborg-hawk , Cyborg-hawk
call :iso.extract discreete , Discreete
call :iso.extract dlc.boot , DLCBoot
call :iso.extract drweb , Dr.Web
call :iso.extract eset_sysrescue , Eset
call :iso.extract hbcd_pe , HirensBoot
call :iso.extract phoenixos , PhoenixOS
call :iso.extract primeos , PrimeOS
call :iso.extract -elite- , Weakerthan
call :iso.extract wnl8 , WeakNet
call :iso.extract lionsec , LionSec
call :iso.extract subgraph-os , Subgraph-os
call :iso.extract Sergei_Strelec , Strelec
call :iso.extract systemrescuecd , SystemRescueCD
wincdemu /uninstall
:modules.specialiso
:: disabled iso linux run on fat32 partition (hidden partition)
call :check.diskInfo
call :checkdisktype
if "%usb%"=="true" if "%GPT%"=="true" goto :modules.populariso
:: check special iso type
call :checkISO specialiso modules.populariso
cd /d "%ducky%\BOOT"
call :get.config Device esp config.ini
set /a "esp=%esp%+0"
set /a "size=0"
call :colortool
for /f "tokens=*" %%x in ('dir /s /a /b "specialiso"') do set /a "size+=%%~zx"
set /a "size=%size%/1024/1024"
:install.speiso
call :get.path rpath %ESP1%
if %size% LEQ %esp% (
if exist "%bindir%\specialiso\*.iso" (
cls & echo. & echo %_lang0204_% & echo.
cd /d "%bindir%"
call :copy.hidden "specialiso" "%rpath%\ISO"
)
) else (
call :colortool
echo.
call :printc "%_lang0205_%"
call :printc "----------------------------------------------------------------------"
call :printc "%_lang0206_%"
call :printc "%_lang0207_%"
call :printc "%_lang0208_%"
call :printc "----------------------------------------------------------------------"
timeout /t 15 >nul
)
:modules.populariso
:: copy all ISO to multiboot
call :colortool
echo.
echo %_lang0209_%
for /f "tokens=*" %%b in ('dir /a /b "%curpath%\*.iso"') do (
if not exist "%ducky%\ISO\%%b" (
for /f "delims=" %%f in (iso.list) do (
if exist "%curpath%\*%%f*.iso" (
echo %%b | findstr /i /c:"%%f" 1>nul
if errorlevel 1 (
echo false >nul
) else (
robocopy "%curpath%" "%ducky%\ISO" %%b /njh /njs /nc /ns
)
)
)
)
)
:: copy Kaspersky Rescue Disk 18 to multiboot
call :colortool
if exist "%curpath%\krd.iso" (
if not exist "%ducky%\DATA\krd.iso" (
echo.
echo %_symbol_%%spaces%Kaspersky Rescue Disk 18 %_lang0015_%
robocopy "%curpath%" "%ducky%\DATA" krd.iso /njh /njs /nc /ns
)
)
:modules.wim
:: copy all *.wim module on multiboot
call :colortool
echo.
echo %_lang0210_%
echo.
for /f "delims=" %%f in (wim.list) do (
if not exist "%ducky%\WIM\%%f" (
if not exist "%ducky%\APPS\%%f" (
if exist "%curpath%\%%f.wim" (
robocopy "%curpath%" "%ducky%\WIM" %%f.wim /njh /njs /nc /ns
)
if exist "%curpath%\%%f.7z" (
robocopy "%curpath%" "%ducky%\WIM" %%f.7z /njh /njs /nc /ns
)
)
)
)
:: rename and move all *.wim to the destination
cd /d "%ducky%\WIM"
if exist *w*8*1*.wim (
move /y *w*8*1*.wim WIM
cd /d "%ducky%\WIM"
ren *w*8*1*64* w8.1se64.wim
ren *w*8*1*32* w8.1se32.wim
ren *w*8*1*86* w8.1se32.wim
cd /d "%ducky%"
)
:: rename winpe
if exist *w*10*64* ren *w*10*64* w10pe64.wim
if exist *w*10*32* ren *w*10*32* w10pe32.wim
if exist *w*10*86* ren *w*10*86* w10pe32.wim
if exist *w*8*64* ren *w*8*64* w8pe64.wim
if exist *w*8*32* ren *w*8*32* w8pe32.wim
if exist *w*8*86* ren *w*8*86* w8pe32.wim
if exist *w*7*32* ren *w*7*32* w7pe32.wim
if exist *xp* ren *xp* XP.wim
:: rename apps & tools for winpe
if exist *dr*v*.wim move /y *drv*.wim %ducky%\APPS >nul
if exist *dr*v*.iso move /y *drv*.iso %ducky%\APPS >nul
if exist *app*.wim move /y *app*.wim %ducky%\APPS >nul
if exist *app*.iso move /y *app*.iso %ducky%\APPS >nul
if exist *tool*.wim move /y *tool*.wim %ducky%\APPS >nul
if exist *tool*.iso move /y *tool*.iso %ducky%\APPS >nul
:: Install Wim Sources Module
if not exist "%ducky%\WIM\bootx64.wim" if not exist "%ducky%\WIM\bootx86.wim" (
if exist "%curpath%\*Wim*Sources*Module*.7z" (
cls & echo. & echo %_lang0213_%
7z x "%curpath%\*Wim*Sources*Module*.7z" -o"%ducky%\" -aoa -y >nul
cd /d "%bindir%\secureboot\EFI\Boot\backup\WinSetupISOWIM"
if exist winsetupia32.efi copy winsetupia32.efi "%ducky%\EFI\BOOT" /y >nul
if exist winsetupx64.efi copy winsetupx64.efi "%ducky%\EFI\BOOT" /y >nul
cd /d "%bindir%\config"
if exist bootisowim copy bootisowim "%ducky%\BOOT\bootmgr" /y >nul
)
)
:: Windows Install ISO Module (ISO method)
cd /d "%ducky%\WIM"
if not exist "bootisox64.wim" if not exist "bootisox86.wim" (
cd /d "%curpath%"
if exist "*WinSetup*ISO*Module*.7z" (
cls & echo. & echo %_lang0218_%
7z x "*WinSetup*ISO*Module*.7z" -o"%ducky%\WIM\" -aoa -y
)
)
:: Install Grub2 File Manager
call :colortool
set "list=grubfmia32.efi grubfmx64.efi grubfm.iso"
if exist "%curpath%\grubfm-*.7z" (
cls & echo.
echo %_symbol_%%spaces%%_lang0224_%
7z x "%curpath%\grubfm-*.7z" -o"%ducky%\EFI\Boot\" %list% -r -y >nul
)
:: copy all *.exe module on multiboot
cd /d "%curpath%"
if exist "*portable.*" (
cls & echo. & echo %_lang0219_%
7z x "*portable.*" -o"%ducky%\PortableApps\" -aoa -y >nul
)
:: return iso file to modules folder
cd /d "%bindir%"
call :moveISO specialiso
call :moveISO isoextract
for /f "tokens=*" %%i in ('dir /s /a /b "%ducky%\BOOT\namelist\temp"') do set /a tsize+=%%~zi
if defined tsize (move /y "%ducky%\BOOT\namelist\temp\*.*" "%ducky%\BOOT\namelist\" >nul)
rd /s /q "%ducky%\BOOT\namelist\temp"
:: update config for Grub2
call "%bindir%\config\main.bat"
cd /d "%bindir%"
rd /s /q specialiso >nul
rd /s /q isoextract >nul
call :clean.bye
:: =========================================
:: EXTRAL FEATURES
:: =========================================
:extraFeatures
set "curdir=%~dp0"
call :colortool
call :multibootscan skip
call :gather.info
:extra.main
call :colortool "Extra Features"
echo.
call :printc "====================================================================="
call :printc "%_lang0819_%"
call :printc "====================================================================="
call :printj "[ a ] = %_lang0821_%" "[ i ] = %_lang0829_%"
call :printj "[ b ] = %_lang0822_%" "[ j ] = %_lang0830_%"
call :printj "[ c ] = %_lang0823_%" "[ k ] = %_lang0831_%"
call :printj "[ d ] = %_lang0824_%" "[ l ] = %_lang0832_%"
call :printj "[ e ] = %_lang0825_%" "[ m ] = %_lang0833_%"
call :printj "[ f ] = %_lang0826_%" "[ n ] = %_lang0834_%"
call :printj "[ g ] = %_lang0827_%" "[ o ] = %_lang0835_%"
call :printj "[ h ] = %_lang0828_%" "[ p ] = %_lang0836_%"
call :printc "====================================================================="
echo.
:: ----------------------------------------------
:: a b c d e f g h i j k l m n o p q
:: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
:: ----------------------------------------------
if "%installed%"=="true" goto :extra.online
if "%installed%"=="false" goto :extra.offline
:extra.online
choice /c abcdefghijklmnopqz /cs /n /m "%_symbol_%%spaces%%_lang0020_%"
if errorlevel 18 timeout /t 1 >nul & goto :clean.bye
if errorlevel 17 timeout /t 1 >nul & goto :mainMenu
if errorlevel 16 timeout /t 1 >nul & goto :sortgrub2menu
if errorlevel 15 timeout /t 1 >nul & goto :updatemultiboot
if errorlevel 14 timeout /t 1 >nul & goto :qemuboottester
if errorlevel 13 timeout /t 1 >nul & goto :changelanguage
if errorlevel 12 timeout /t 1 >nul & goto :NTFSdriveprotect
if errorlevel 11 timeout /t 1 >nul & goto :easeconvertdisk
if errorlevel 10 timeout /t 1 >nul & goto :OneFileLinux
if errorlevel 9 timeout /t 1 >nul & goto :fixbootloader
if errorlevel 8 timeout /t 1 >nul & goto :grub2-filemanager
if errorlevel 7 timeout /t 1 >nul & goto :editwinsetupfromUSB
if errorlevel 6 timeout /t 1 >nul & goto :editWinPEbootmanager
if errorlevel 5 timeout /t 1 >nul & goto :setdefaultboot
if errorlevel 4 timeout /t 1 >nul & goto :rEFIndInstaller
if errorlevel 3 timeout /t 1 >nul & goto :cloverinstaller
if errorlevel 2 timeout /t 1 >nul & goto :rEFIndtheme
if errorlevel 1 timeout /t 1 >nul & goto :grub2theme
:extra.offline
choice /c cdhknqz /cs /n /m "%_symbol_%%spaces%%_lang0020_%"
if errorlevel 7 timeout /t 1 >nul & goto :clean.bye
if errorlevel 6 timeout /t 1 >nul & goto :mainMenu
if errorlevel 5 timeout /t 1 >nul & goto :qemuboottester
if errorlevel 4 timeout /t 1 >nul & goto :easeconvertdisk
if errorlevel 3 timeout /t 1 >nul & goto :grub2-filemanager
if errorlevel 2 timeout /t 1 >nul & goto :rEFIndInstaller
if errorlevel 1 timeout /t 1 >nul & goto :cloverinstaller
:: =========================================
:: BEGIN FUNCTIONS
:: =========================================
:set.mode
:: set min cols is 102 to fix the partassist's percent process display (old: 18x70)
set /a row = 25
set /a col = 102
mode con lines=%row% cols=%col%
exit /b 0
:printMissing
call :set.mode
echo. & echo. & echo. & echo. & echo. & echo. & echo.
call :printc " ███▄ ▄███▓ ██▓ ██████ ██████ ██▓ ███▄ █ ▄████ █████▒██▓ ██▓ ▓█████ ██████ "
call :printc "▓██▒▀█▀ ██▒▓██▒▒██ ▒ ▒██ ▒ ▓██▒ ██ ▀█ █ ██▒ ▀█▒ ▓██ ▒▓██▒▓██▒ ▓█ ▀ ▒██ ▒ "
call :printc "▓██ ▓██░▒██▒░ ▓██▄ ░ ▓██▄ ▒██▒▓██ ▀█ ██▒▒██░▄▄▄░ ▒████ ░▒██▒▒██░ ▒███ ░ ▓██▄ "
call :printc "▒██ ▒██ ░██░ ▒ ██▒ ▒ ██▒░██░▓██▒ ▐▌██▒░▓█ ██▓ ░▓█▒ ░░██░▒██░ ▒▓█ ▄ ▒ ██▒"
call :printc "▒██▒ ░██▒░██░▒██████▒▒▒██████▒▒░██░▒██░ ▓██░░▒▓███▀▒ ░▒█░ ░██░░██████▒░▒████▒▒██████▒▒"
call :printc "░ ▒░ ░ ░░▓ ▒ ▒▓▒ ▒ ░▒ ▒▓▒ ▒ ░░▓ ░ ▒░ ▒ ▒ ░▒ ▒ ▒ ░ ░▓ ░ ▒░▓ ░░░ ▒░ ░▒ ▒▓▒ ▒ ░"
call :printc "░ ░ ░ ▒ ░░ ░▒ ░ ░░ ░▒ ░ ░ ▒ ░░ ░░ ░ ▒░ ░ ░ ░ ▒ ░░ ░ ▒ ░ ░ ░ ░░ ░▒ ░ ░"
call :printc "░ ░ ▒ ░░ ░ ░ ░ ░ ░ ▒ ░ ░ ░ ░ ░ ░ ░ ░ ░ ▒ ░ ░ ░ ░ ░ ░ ░ "
call :printc " ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ "
timeout /t 20 >nul & exit
exit /b 0
:colortool
cls
cd /d "%bindir%"
set /a num=%random% %%105 +1
set "itermcolors=%num%.itermcolors"
if "%color%"=="true" goto :skipcheck.color
7z x "colortool.7z" -o"%tmp%" -aos -y >nul
:: Check for DotNet 4.0 Install
cd /d "%tmp%\colortool"
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP" /s | find "v4" > Output.log
if %errorlevel% equ 0 (
colortool -b -q %itermcolors%
set "color=true"
goto :exit.color
) else (
set "color=false"
goto :exit.color
)
:skipcheck.color
cd /d "%tmp%\colortool"
colortool -b -q %itermcolors%
:exit.color
cls
call :set.mode
cd /d "%bindir%"
if not "%~1" == "" set "title=%~1"
title Multiboot Toolkit %version% - %title%
exit /b 0
:permissions
ver | findstr /i "6\.1\." >nul
if %errorlevel% equ 0 set "windows=7"
if not "%windows%"=="7" chcp 65001 >nul
:: BatchGotAdmin (Run as Admin code starts)
cd /d "%temp%"
:: Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
:: If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (goto UACPrompt) else (goto gotAdmin)
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > getadmin.vbs
echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> getadmin.vbs
getadmin.vbs
exit
:gotAdmin
if exist getadmin.vbs del getadmin.vbs
:: BatchGotAdmin (Run as Admin code ends)
exit /b 0
:license
call :colortool "License"
cd /d "%tmp%"
> welcome.vbs (
echo Dim Message, Speak
echo Set Speak=CreateObject^("sapi.spvoice"^)
echo Speak.Speak "Welcome to Multiboot Toolkit %version%"
echo WScript.Sleep 1
echo Speak.Speak "Multiboot Toolkit is the open-source software."
echo Speak.Speak "It's released under General Public Licence."
echo Speak.Speak "You can use, modify and redistribute if you wish."
echo Speak.Speak "Choose a default language to continue..."
)
echo.
call :printc " __ __ _ _ _ _ _ _____ _ _ _ _ "
call :printc "| \/ |_ _| | |_(_) |__ ___ ___| |_ |_ _|__ ___| | |_(_) |_ "
call :printc "| |\/| | || | | _| | '_ \/ _ \/ _ \ _| | |/ _ \/ _ \ | / / | _|"
call :printc "|_| |_|\_,_|_|\__|_|_.__/\___/\___/\__| |_|\___/\___/_|_\_\_|\__|"
call :printc " %version%"
echo.
call :printc " Multiboot Toolkit is the open-source software. It's released under"
call :printc " General Public Licence (GPL). You can use, modify and redistribute"
call :printc " if you wish. "
echo.
call :printc " Thanks to: "
call :printc " ------------------------------------------------------------------"
call :printc " Ha Son, Tayfun Akkoyun, anhdv, lethimaivi, A1ive, Hoang Duch2, ..."
call :printc " ------------------------------------------------------------------"
call :speechOn welcome.vbs
echo.
call :printc "[ 1 ] English [ 2 ] Vietnamese [ 3 ] Turkish [ 4 ] Chinese"
echo.
echo.
:: get config here to improve the loading time when starting the script.
cd /d "%~dp0"
call :get.freeDrive
call :get.config PartitionLabels ESP1
call :get.config PartitionLabels ESP2
call :get.config PartitionLabels DATA
call :get.config BootloaderTheme rtheme
call :get.config BootloaderTheme gtheme
choice /c 1234a /cs /n /m "$%spaces%Choose a default language [ ? ] = "
if errorlevel 1 set "lang=English"
if errorlevel 2 set "lang=Vietnam"
if errorlevel 3 set "lang=Turkish"
if errorlevel 4 set "lang=SimplifiedChinese"
if errorlevel 5 set "lang=autodetect"
call :speechOff welcome.vbs
call :partassist.init
:: change language
call :colortool
call language.bat
goto :mainMenu
exit /b 0
:partassist.init
cls
echo.
cd /d "%bindir%"
echo Loading, Please wait...
7z x "partassist.7z" -o"%tmp%" -aos -y >nul
path=%path%;%bindir%;%tmp%;%tmp%\partassist
:: begin preparing file
call :extract.rEFInd
cd /d "%tmp%\partassist"
if "%processor_architecture%"=="x86" (
SetupGreen32 -i >nul
LoadDrv_Win32 -i >nul
) else (
SetupGreen64 -i >nul
LoadDrv_x64 -i >nul
)
> cfg.ini (
echo [Language]
echo LANGUAGE=lang\%langpa%.txt;%langcode%
echo LANGCHANGED=1
echo [Version]
echo Version=4
echo [Product Version]
echo v=2
echo Lang=%langpa%
echo [CONFIG]
echo COUNT=2
echo KEY=AOPR-21ROI-6Y7PL-Q4118
echo [PA]
echo POPUPMESSAGE=1
)
> winpeshl.ini (
echo [LaunchApp]
echo AppPath=%tmp%\partassist\PartAssist.exe
)
cls
exit /b 0
:clean.bye
call :colortool
for /f %%b in (
'wmic volume get driveletter^, label ^| findstr /i "%DATA%"'
) do set "ducky=%%b"
for /f "delims=" %%f in (hide.list) do (
if exist "%ducky%\%%f" attrib +s +h "%ducky%\%%f"
if exist "%ducky%\ISO\%%f" attrib +s +h "%ducky%\ISO\%%f"
if exist "%ducky%\WIM\%%f" attrib +s +h "%ducky%\WIM\%%f"
)
cd /d "%tmp%\partassist"
if "%processor_architecture%"=="x86" (
SetupGreen32 -u >nul
LoadDrv_Win32 -u >nul
) else (
SetupGreen64 -u >nul
LoadDrv_x64 -u >nul
)
cd /d "%tmp%"
:: clean up the trash and exit
set "dlist=colortool curl driveprotect gdisk grub2 partassist CLOVER rEFInd rEFInd_themes"
for %%d in (%dlist%) do (
if exist "%%d" rmdir "%%d" /s /q >nul
)
set "flist=clover* grubfm* hide.vbs Output.log qemuboottester.exe wincdemu.exe wget*"
for %%f in (%flist%) do (
if exist "%%f" del "%%f" /s /q >nul
)
> thanks.vbs (
echo Dim Message, Speak
echo Set Speak=CreateObject^("sapi.spvoice"^)
echo Speak.Speak "Thank you for using Multiboot Toolkit"
)
cls
echo. & echo. & echo. & echo. & echo. & echo. & echo.
call :printc " __ __ __ "
call :printc "| |_| |--.---.-.-----.| |--. .--.--.-----.--.--."
call :printc "| _| | _ | || < | | | _ | | |"
call :printc "|____|__|__|___._|__|__||__|__| |___ |_____|_____|"
call :printc " |_____| "
call :speechOn thanks.vbs
timeout /t 4 >nul
del /s /q thanks.vbs >nul
exit
exit /b 0
:check.diskInfo
set GPT=false
for /f "tokens=4,5,8" %%b in (
'echo list disk ^| diskpart ^| find /i "Disk %disk%"'
) do (
set /a disksize=%%b
set diskunit=%%c
if /i "%%d"=="*" set GPT=true
)
for /f "tokens=1 delims=\\.\" %%b in (
'wmic diskdrive list brief ^| find /i "physicaldrive%disk%"'
) do set "model=%%b"
exit /b 0
:get.path
:: find and use volume id instead of drive letter for a hidden partition
for /f %%b in (
'wmic volume get label^, id ^| findstr %~2'
) do set "tpath=%%b"
if exist "%tpath%\EFI\BOOT\mark" (
for /f "tokens=*" %%b in (%tpath%\EFI\BOOT\mark) do set "author=%%b"
)
if not "%author%"=="niemtin007" echo %~2 not found! & pause >nul & exit
set "%~1=%tpath%"
exit /b 0
:copy.hidden
:: copy file/folder to hidden partition using volume id
copy %~1 %~2 /y
for /f "tokens=*" %%i in ('dir /a:d /b "%~1"') do (
if not exist %~2\%%i md %~2\%%i
call :copy.hidden %~1\%%i %~2\%%i
)
exit /b 0
:delete.hidden
del %~1 /s /q /f
for /f "tokens=*" %%i in ('dir /a:d /b "%~1"') do (
call :delete.hidden %~1\%%i
)
exit /b 0
:get.freeDrive
set "freedrive="
:: http://wiki.uniformserver.com/index.php/Batch_files:_First_Free_Drive#Final_Solution
for %%a in (Z Y X W V U T S R Q P O N M L K J I H G F E D C) do (
cd %%a: 1>>nul 2>&1 & if errorlevel 1 set freedrive=%%a
)
exit /b 0
:check.letter
echo.
echo %_symbol_%%spaces%%_lang0123_%
call :get.freeDrive
:: get volume number instead of specifying a drive letter for missing drive letter case
for /f "tokens=2" %%b in (
'echo list volume ^| diskpart ^| find /i "%DATA%"'
) do set "volume=%%b"
vol %~1 >nul 2>&1
if errorlevel 0 if exist "%~1" set "volume=%~1"
:: assign drive letter
(
echo select volume %volume%
echo assign letter=%freedrive%
) | diskpart >nul
exit /b 0
:scan.label
set "ducky="
set "online=false"
:: get drive letter from label
for /f %%b in (
'wmic volume get driveletter^, label ^| findstr /i "%~1"'
) do set "ducky=%%b"
:: in case drive letter missing the ducky is the %~1 argument
vol %ducky% >nul 2>&1
if errorlevel 1 (
call :check.letter
call :scan.label %~1
) else (
if exist "%ducky%\EFI\BOOT\mark" set online=true
)
:: get disk number from drive letter
for /f "tokens=2 delims= " %%b in (
'wmic path win32_logicaldisktopartition get antecedent^, dependent ^| find "%ducky%"'
) do set "diskscan=%%b"
if defined diskscan set /a "diskscan=%diskscan:~1,1%"
exit /b 0
:check.author
set label=false
set author=whoiam
set installed=false
:: check disk unavailable
vol %~1 >nul 2>&1
if errorlevel 1 set label=BBP
for /f "tokens=1-5*" %%1 in ('vol %~1') do (
set label=%%6 & goto :break.label
)
:break.label
if exist "%~1\EFI\BOOT\mark" (
for /f "tokens=*" %%b in (%~1\EFI\BOOT\mark) do set "author=%%b"
)
if "%author%"=="niemtin007" (
if "%label%"=="%ESP2% " set installed=true
if "%label%"=="%ESP1% " set installed=true
if "%label%"=="%DATA% " set installed=true
) else (
if "%label%"=="BBP" set installed=true
)
exit /b 0
:checkdisktype
:: reset all disks variable
set "virtualdisk=false"
set "harddisk=false"
set "usb=false"
set "externaldisk=false"
set /a disk=%disk%+0
:: check.virtualdisk
wmic diskdrive get name, model | find /i "Msft Virtual Disk SCSI Disk Device" | find /i "\\.\physicaldrive%disk%" >nul
if not errorlevel 1 set "virtualdisk=true"
wmic diskdrive get name, model | find /i "Microsoft Virtual Disk" | find /i "\\.\physicaldrive%disk%" >nul
if not errorlevel 1 set "virtualdisk=true"
wmic diskdrive get name, model | find /i "Microsoft Sanal Diski" | find /i "\\.\physicaldrive%disk%" >nul
if not errorlevel 1 set "virtualdisk=true"
:: check.harddisk
wmic diskdrive get name, mediatype | find /i "Fixed hard disk media" | find /i "\\.\physicaldrive%disk%" >nul
if not errorlevel 1 set "harddisk=true"
if "%virtualdisk%"=="true" set "harddisk=false"
:: check.usbdisk
wmic diskdrive get name, mediatype | find /i "Removable Media" | find /i "\\.\physicaldrive%disk%" >nul
if not errorlevel 1 set "usb=true"
:: check.externaldisk
wmic diskdrive get name, mediatype | find /i "External hard disk media" | find /i "\\.\physicaldrive%disk%" >nul
if not errorlevel 1 set "externaldisk=true"
exit /b 0
:count.partition
set "partcount="
:: count the total number of partition in a disk
for /f "tokens=3 delims=#" %%b in (
'wmic partition get name ^| findstr /i "#%disk%,"'
) do set "partcount=%%b"
exit /b 0
:set.partnum
if "%usb%"=="true" if "%secureboot%"=="n" (
set /a rpart=1
goto :%~1
)
if "%usb%"=="true" if "%secureboot%"=="y" (
set /a rpart=2
set /a mpart=1
set /a spart=1
goto :%~2
)
if "%secureboot%"=="n" (
set /a rpart=0
set /a mpart=1