This repository has been archived by the owner on Dec 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
setup.bat
2461 lines (1980 loc) · 89.1 KB
/
setup.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
setlocal EnableExtensions
REM : ------------------------------------------------------------------
REM : main
setlocal EnableDelayedExpansion
color 4F
REM : CEMU's Batch FrameWork Version
set "BFW_VERSION=V23-1"
REM : version of GFX packs created
set "BFW_GFXP_VERSION=V6"
set "THIS_SCRIPT=%~0"
title -= BatchFw %BFW_VERSION% setup =-
REM : directory of this script
set "SCRIPT_FOLDER="%~dp0"" && set "BFW_PATH=!SCRIPT_FOLDER:\"="!"
set "BFW_RESOURCES_PATH="!BFW_PATH:"=!\resources""
set "cmdOw="!BFW_RESOURCES_PATH:"=!\cmdOw.exe""
!cmdOw! @ /MAX > NUL 2>&1
REM : checking THIS_SCRIPT path
call:checkPathForDos "!THIS_SCRIPT!" > NUL 2>&1
set /A "cr=!ERRORLEVEL!"
if !cr! NEQ 0 (
echo ERROR Remove DOS reserved characters from the path "!THIS_SCRIPT!"^(such as ^&^, %% or ^^!^)^, cr=!cr!
pause
exit 1
)
for %%a in (!BFW_PATH!) do set "parentFolder="%%~dpa""
for %%a in (!BFW_PATH!) do set "drive=%%~da"
set "GAMES_FOLDER=!parentFolder!"
if not [!GAMES_FOLDER!] == ["!drive!\"] set "GAMES_FOLDER=!parentFolder:~0,-2!""
REM : paths and tools used
set "BFW_TOOLS_PATH="!BFW_PATH:"=!\tools""
set "createWiiuSDcard="!BFW_TOOLS_PATH:"=!\createWiiuSDcard.bat""
set "dumpGames="!BFW_TOOLS_PATH:"=!\dumpGamesFromWiiu.bat""
set "BFW_WIIU_FOLDER="!GAMES_FOLDER:"=!\_BatchFw_WiiU""
set "rarExe="!BFW_RESOURCES_PATH:"=!\rar.exe""
set "brcPath="!BFW_RESOURCES_PATH:"=!\BRC_Unicode_64\BRC64.exe""
set "quick_Any2Ico="!BFW_RESOURCES_PATH:"=!\quick_Any2Ico.exe""
set "fnrPath="!BFW_RESOURCES_PATH:"=!\fnr.exe""
set "xmlS="!BFW_RESOURCES_PATH:"=!\xml.exe""
set "Start="!BFW_RESOURCES_PATH:"=!\vbs\Start.vbs""
set "StartWait="!BFW_RESOURCES_PATH:"=!\vbs\StartWait.vbs""
set "StartHidden="!BFW_RESOURCES_PATH:"=!\vbs\StartHidden.vbs""
set "StartHiddenWait="!BFW_RESOURCES_PATH:"=!\vbs\StartHiddenWait.vbs""
set "StartMinimizedWait="!BFW_RESOURCES_PATH:"=!\vbs\StartMinimizedWait.vbs""
set "browseFolder="!BFW_RESOURCES_PATH:"=!\vbs\BrowseFolderDialog.vbs""
set "browseFile="!BFW_RESOURCES_PATH:"=!\vbs\BrowseFileDialog.vbs""
set "BFW_LOGS="!BFW_PATH:"=!\logs""
set "logFile="!BFW_LOGS:"=!\Host_!USERDOMAIN!.log""
set "glogFile="!BFW_LOGS:"=!\gamesLibrary.log""
REM : replace ref in glogFile
set "msg="!BFW_VERSION! installed, version of graphic packs=!BFW_GFXP_VERSION!""
call:log2GamesLibraryFile !msg!
set "wiiTitlesDataBase="!BFW_RESOURCES_PATH:"=!\WiiU-Titles-Library.csv""
set "ACTIVE_ADAPTER=NONE"
REM : check if folder name contains forbiden character for batch file
call:securePathForDos !GAMES_FOLDER! SAFE_PATH
if not [!GAMES_FOLDER!] == [!SAFE_PATH!] (
echo ERROR ^: please rename your folders to have this compatible path
echo !SAFE_PATH!
pause
exit 95
)
if exist !logFile! goto:setChcp
REM ----------------------------------------------------------------------------------------------
REM First run checks
REM ----------------------------------------------------------------------------------------------
echo =========================================================
echo BatchFw pre-requisites check^.^.^.
echo =========================================================
REM : check if not Linux tools are defined in the environnement
echo test | find /I "test" > NUL
if !ERRORLEVEL! NEQ 0 (
echo Found linux tools in your environnement
echo Please define them add the end of your path if you
echo want to launch BatchFw
pause
exit 2
)
echo DOS only environnement ^: OK
REM : check if file system is NTFS (BatchFw use Symlinks and need to be installed on a NTFS volume)
for %%i in (!BFW_PATH!) do for /F "tokens=2 delims=~=" %%j in ('wmic path win32_volume where "Caption='%%~di\\'" get FileSystem /value 2^>NUL ^| find /I /V "NTFS"') do (
echo This volume is not an NTFS one^!
echo BatchFw use Symlinks and need to be installed on a NTFS volume
pause
exit 3
)
echo File system NTFS ^: OK
REM : check rights to create links
pushd !GAMES_FOLDER!
set "linkCheck="!BFW_PATH:"=!\linkCheck""
if exist !linkCheck! rmdir /Q !linkCheck! > NUL 2>&1
mklink /J !linkCheck! !TMP! > NUL 2>&1
if !ERRORLEVEL! NEQ 0 (
echo This user is not allowed to create links^!
echo BatchFw use Symlinks^, please contact !USERDOMAIN! administrator
pause
exit 4
)
echo Rights to create symlinks ^: OK
if exist !linkCheck! rmdir /Q !linkCheck! > NUL 2>&1
REM : check rights to launch vbs scripts
for /F "tokens=3" %%a in ('reg query "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Script Host\Settings" /v Enabled 2^>NUL') do (
set "value=%%a"
set /A "value=!value: =!"
if !value! EQU 0 (
echo Launching VBS scripts is not allowed^!
echo HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Script Host\Settings\Enabled ^<^> 1
echo value=[!value!]
echo BatchFw use VBS scripts^, please contact !USERDOMAIN! administrator
pause
exit 5
) else (
echo Rights to launch vbs scripts ^: OK
)
)
java -version > NUL 2>&1
if !ERRORLEVEL! EQU 0 (
echo Java is installed ^(optional^) ^: OK
) else (
echo Java is installed ^(optional^) ^: WARNING
)
echo ---------------------------------------------------------
timeout /T 4 > NUL 2>&1
cls
REM ----------------------------------------------------------------------------------------------
REM : initialize log file for current host (if needed)
call:initLogForHost
REM : create JNUSTool config file
set "config="!BFW_RESOURCES_PATH:"=!\JNUST\config""
if not exist !config! call:createJNUSToolConfigFile > !config!
:setChcp
REM : set current char codeset
call:setCharSet
REM : clean log files specific to a launch
REM : clean log files specific to a launch
set "tobeDelete="!BFW_PATH:"=!\logs\fnr_*.*""
del /F /S !toBeDelete! > NUL 2>&1
set "tobeDelete="!BFW_PATH:"=!\logs\jnust_*.*""
del /F /S !toBeDelete! > NUL 2>&1
set "tobeDelete="!BFW_PATH:"=!\logs\fnr""
rmdir /Q /S !toBeDelete! > NUL 2>&1
REM : flush logFile of BFW_VERSION
call:cleanHostLogFile BFW_VERSION
set "msg="BFW_VERSION=%BFW_VERSION%""
call:log2HostFile !msg!
REM : get screen resolution
pushd !BFW_RESOURCES_PATH!
for /f "tokens=2,10-11" %%a in ('cmdOw.exe /p') do (
if "%%a"=="0" set "scrWidth=%%b" & set "scrHeight=%%c"
)
REM : flush logFile of RESOLUTION
call:cleanHostLogFile RESOLUTION
set "msg="RESOLUTION=!scrWidth!x!scrHeight!""
call:log2HostFile !msg!
REM : flush logFile of REFRESH_RATE
call:cleanHostLogFile REFRESH_RATE
for /F "tokens=2 delims=~=" %%i in ('wmic path Win32_VideoController get currentrefreshrate /value 2^>NUL ^| findStr /R "=[0-9]*.$"') do set /A "refreshRate=%%i"
set "msg="REFRESH_RATE=!refreshRate!""
call:log2HostFile !msg!
REM : cd to GAMES_FOLDER
pushd !GAMES_FOLDER!
REM : rename folders that contains forbiden characters : & ! . ( )
wscript /nologo !StartHiddenWait! !brcPath! /DIR^:!GAMES_FOLDER! /REPLACECI^:^^!^: /REPLACECI^:^^^&^: /REPLACECI^:^^.^: /EXECUTE
REM : check if DLC and update folders are presents (some games need to be prepared)
call:checkGamesToBePrepared
REM : rename folders that contains forbiden characters : ( )
wscript /nologo !StartHiddenWait! !brcPath! /DIR^:!GAMES_FOLDER! /REPLACECI^:^^(^:[ /REPLACECI^:^^)^:] /EXECUTE
REM : checking arguments
set /A "nbArgs=0"
:continue
if "%~1"=="" goto:end
set "args[%nbArgs%]="%~1""
set /A "nbArgs +=1"
shift
goto:continue
:end
if %nbArgs% EQU 0 (
title -= Install BatchFw %BFW_VERSION% =-
goto:beginSetup
)
if %nbArgs% NEQ 1 (
echo ERROR on arguments passed^(%nbArgs%^)
echo SYNTAXE^: "!THIS_SCRIPT!" OUTPUT_FOLDER
echo given {%*}
pause
exit 9
)
REM : get and check OUTPUT_FOLDER
set "OUTPUT_FOLDER=!args[0]!"
for %%a in (!OUTPUT_FOLDER!) do set "drive=%%~da"
if [!OUTPUT_FOLDER!] == ["!drive!\"] set "OUTPUT_FOLDER="!drive!""
:beginSetup
call:cleanHostLogFile BFW_VERSION
set "msg="BFW_VERSION=%BFW_VERSION%""
call:log2HostFile !msg!
echo Checking for update ^.^.^.
REM : update BatchFw
set "ubw="!BFW_TOOLS_PATH:"=!\updateBatchFw.bat""
call !ubw!
set /A "cr=!ERRORLEVEL!"
if !cr! EQU 0 (
echo BatchFw updated^, please relaunch
timeout /t 4 > NUL 2>&1
set "ChangeLog="!BFW_PATH:"=!\Change.log""
wscript /nologo !Start! "%windir%\System32\notepad.exe" !ChangeLog!
exit 75
)
timeout /t 2 > NUL 2>&1
set "readme="!BFW_PATH:"=!\BatchFw_readme.txt""
set /A "QUIET_MODE=0"
if exist !readme! set /A "QUIET_MODE=1"
:scanGamesFolder
set "OUTPUT_FOLDER=!OUTPUT_FOLDER:\\=\!"
cls
if %nbArgs% EQU 0 (
echo =========================================================
echo CEMU^'s Batch FrameWork !BFW_VERSION! installer
echo =========================================================
echo ^(in case of false input close this main window to cancel^)
if %QUIET_MODE% EQU 0 (
echo ---------------------------------------------------------
echo BatchFw is a batch framework created to launch easily all
echo your RPX games ^(loadiines format^) using many versions of
echo CEMU^.
echo.
echo It is now limited only to CEMU's versions ^>=1^.11 that^:
echo -support the -mlc argument
echo -use the last saves format
echo.
echo It gathers all game^'s data in each game^'s folder and so
echo ease the CEMU^'s update process and make your loadiine
echo games library portable^.
)
) else (
echo =========================================================
echo Set your BatchFw^'s settings and register many versions
echo of CEMU
echo =========================================================
echo ^(in case of false input close this main window to cancel^)
)
echo ---------------------------------------------------------
echo Scanning your games library^.^.^.
echo ---------------------------------------------------------
REM : check if exist game's folder(s) containing non supported characters
set "tmpFile="!BFW_LOGS:"=!\detectInvalidGamesFolder.log""
dir /B /A:D > !tmpFile! 2>&1
type !tmpFile! | find "?" > NUL 2>&1 && (
echo =========================================================
echo ERROR Unknown characters found in game^'s folder^(s^) that is not handled by your current DOS charset ^(%CHARSET%^)
echo List of game^'s folder^(s^)^:
echo ---------------------------------------------------------
type !tmpFile! | find "?"
del /F !tmpFile!
echo ---------------------------------------------------------
echo Fix-it by removing characters here replaced in the folder^'s name by ^'^?^'
echo Otherwise, they will be ignored by batchFW^!
echo =========================================================
pause
)
REM : clean BFW_LOGS
pushd !BFW_LOGS!
for /F "delims=~" %%i in ('dir /B /S /A:D 2^> NUL') do rmdir /Q /S "%%i" > NUL 2>&1
for /F "delims=~" %%i in ('dir /B /S /A:L 2^> NUL') do rmdir /Q /S "%%i" > NUL 2>&1
REM : cd to GAMES_FOLDER
pushd !GAMES_FOLDER!
REM : scanning games folder (parent folder of _CEMU_Batch_Framework folder)
set /A NB_GAMES_VALID=0
REM : searching for code folder to find in only one rpx file (the bigger one)
for /F "delims=~" %%g in ('dir /B /S /A:D code 2^> NUL ^| find /I /V "\mlc01" ^| find /I /V "\_BatchFw_Install"') do (
set "codeFullPath="%%g""
set "GAME_FOLDER_PATH=!codeFullPath:\code=!"
REM : check path
call:checkPathForDos !GAME_FOLDER_PATH! > NUL 2>&1
set /A "cr=!ERRORLEVEL!"
if !cr! EQU 0 (
REM : check if folder name contains forbiden character for batch file
set "tobeLaunch="!BFW_PATH:"=!\tools\detectAndRenameInvalidPath.bat""
call !tobeLaunch! !GAME_FOLDER_PATH!
set /A "cr=!ERRORLEVEL!"
if !cr! GTR 1 echo Please rename the game^'s folder to be DOS compatible^, otherwise it will be ignored by BatchFW ^^!
if !cr! EQU 1 goto:scanGamesFolder
call:searchGameIn
) else (
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
for %%a in (!GAME_FOLDER_PATH!) do set "folderName=%%~nxa"
echo !folderName!^: Unsupported characters found^, rename it otherwise it will be ignored by BatchFW ^^!
for %%a in (!GAME_FOLDER_PATH!) do set "basename=%%~dpa"
REM : windows forbids creating folder or file with a name that contains \/:*?"<>| but &!% are also a problem with dos expansion
set "str="!folderName!""
set "str=!str:&=!"
set "str=!str:\!=!"
set "str=!str:%%=!"
set "str=!str:.=!"
set "str=!str:?=!"
set "str=!str:\"=!"
set "str=!str:^=!"
set "newFolderName=!str:"=!"
set "newName="!basename!!newFolderName:"=!""
set /A "attempt=1"
:tryToMove
call:getUserInput "Renaming folder for you? (y, n) : " "y,n" ANSWER
if [!ANSWER!] == ["y"] (
move /Y !GAME_FOLDER_PATH! !newName! > NUL 2>&1
if !ERRORLEVEL! NEQ 0 (
if !attempt! EQU 1 (
!MessageBox! "Check failed on !GAME_FOLDER_PATH:"=!^, close any program that could use this location" 4112
set /A "attempt+=1"
goto:tryToMove
)
REM : basename of GAME FOLDER PATH to get GAME_TITLE
for /F "delims=~" %%g in (!GAME_FOLDER_PATH!) do set "GAME_TITLE=%%~nxg"
call:fillOwnerShipPatch !GAME_FOLDER_PATH! "!GAME_TITLE!" patch
!MessageBox! "Check still failed^, take the ownership on !GAME_FOLDER_PATH:"=! with running as an administrator the script !patch:"=!^. If it^'s done^, do you wish to retry^?" 4116
if !ERRORLEVEL! EQU 6 goto:tryToMove
)
)
if [!ANSWER!] == ["y"] if !ERRORLEVEL! EQU 0 timeout /t 2 > NUL 2>&1 && goto:scanGamesFolder
if [!ANSWER!] == ["y"] if !ERRORLEVEL! NEQ 0 echo Failed to rename game^'s folder ^(contain ^'^^!^'^?^), please do it by yourself otherwise game will be ignored^!
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
)
)
echo =========================================================
echo ^> !NB_GAMES_VALID! valid games found
if !NB_GAMES_VALID! EQU 0 (
echo No RPX games were found
echo.
call:getUserInput "Dumps games from your Wii-U (1), install games coming with update and/or DLC (2), download games (3) or cancel (c) ?" "1,2,3,c" ANSWER
if [!ANSWER!] == ["c"] (
echo So exiting^.^.^.
echo _BatchFW_Install folder must be located in your loadiines ^(^*^.rpx^) games folder
timeout /T 8 > NUL 2>&1
exit 55
)
if [!ANSWER!] == ["1"] goto:useWiiU
if [!ANSWER!] == ["2"] (
REM : calling importGames.bat
set "tobeLaunch="!BFW_TOOLS_PATH:"=!\importGames.bat""
call !tobeLaunch! !GAMES_FOLDER!
)
if [!ANSWER!] == ["3"] (
REM : calling downloadGames.bat
set "tobeLaunch="!BFW_TOOLS_PATH:"=!\downloadGames.bat""
call !tobeLaunch! !GAMES_FOLDER!
)
timeout /T 3 > NUL 2>&1
cls
)
if %QUIET_MODE% EQU 0 (
echo ---------------------------------------------------------
echo This is the very first time you install BatchFw ^:
echo ---------------------------------------------------------
call:getUserInput "Read the goals of BatchFW? (y,n = default in 6s) : " "n,y" ANSWER 6
if [!ANSWER!] == ["n"] goto:goalsOK
set "tmpFile="!BFW_PATH:"=!\doc\goal.txt""
wscript /nologo !StartWait! "%windir%\System32\notepad.exe" !tmpFile!
:goalsOK
call:getUserInput "Read informations on CEMU interfaces history? (y,n = default in 6s) : " "n,y" ANSWER 6
if [!ANSWER!] == ["n"] goto:iFOK
set "tmpFile="!BFW_PATH:"=!\doc\cemuInterfacesHistory.txt""
wscript /nologo !StartWait! "%windir%\System32\notepad.exe" !tmpFile!
:iFOK
call:getUserInput "Read how graphic packs are handled? (y,n = default in 6s) : " "n,y" ANSWER 6
if [!ANSWER!] == ["n"] goto:gfxPacksOK
set "tmpFile="!BFW_PATH:"=!\doc\graphicPacksHandling.txt""
wscript /nologo !StartWait! "%windir%\System32\notepad.exe" !tmpFile!
:gfxPacksOK
call:getUserInput "Read about users saves/extra slots feature? (y,n = default in 6s) : " "n,y" ANSWER 6
if [!ANSWER!] == ["n"] goto:savesOK
set "tmpFile="!BFW_PATH:"=!\doc\userSavesAndSlots.txt""
wscript /nologo !StartWait! "%windir%\System32\notepad.exe" !tmpFile!
:savesOK
call:getUserInput "Read about Wii-U transferts feature? (y,n = default in 6s) : " "n,y" ANSWER 6
if [!ANSWER!] == ["n"] goto:useProgressBar
set "tmpFile="!BFW_PATH:"=!\doc\syncWii-U.txt""
wscript /nologo !StartWait! "%windir%\System32\notepad.exe" !tmpFile!
)
:useProgressBar
if %nbArgs% EQU 0 call:setProgressBar
echo ---------------------------------------------------------
echo You can import ^'ready to use^' mods for your games^.
echo Note that if you use more than one mod you^'d better use BCML to create a
echo resulting mod ^'ready to use^'^.
echo.
call:getUserInput "Have you got some mods for your games that you wish to import (y,n)? " "y,n" ANSWER
if [!ANSWER!] == ["n"] goto:askGpCheckUpdate
:askAnotherModFolder
set "im="!BFW_TOOLS_PATH:"=!\importModsForAllGames.bat""
wscript /nologo !StartWait! !im!
call:getUserInput "Do you want to add another mod folder (y,n = default in 10s)?" "n,y" ANSWER 10
if [!ANSWER!] == ["y"] goto:askAnotherModFolder
echo Next time use the shortcut in
echo Wii-U Games^\_BatchFw^\Tools^\Graphic packs^\Import Mods for my games^.lnk
echo ^> Mods were imported in each game^'s folder
:askGpCheckUpdate
echo ---------------------------------------------------------
REM : flush logFile of CHECK_UPDATE
for /F "tokens=2 delims=~=" %%i in ('type !logFile! ^| find "CHECK_UPDATE" 2^>NUL') do call:cleanHostLogFile CHECK_UPDATE
call:getUserInput "Do you want to check for BatchFW's update (y = default in 10s, n)? " "y,n" ANSWER 10
if [!ANSWER!] == ["y"] (
set "msg="CHECK_UPDATE=YES""
call:log2HostFile !msg!
)
echo ---------------------------------------------------------
REM : flush logFile of COMPLETE_GP
for /F "tokens=2 delims=~=" %%i in ('type !logFile! ^| find "COMPLETE_GP" 2^>NUL') do call:cleanHostLogFile COMPLETE_GP
choice /C yn /N /M "Do you want BatchFW to complete graphic packs? (y,n):"
if !ERRORLEVEL! EQU 1 (
set "msg="COMPLETE_GP=YES""
call:log2HostFile !msg!
goto:askRatios
)
REM : else
goto:askScreenMode
:askRatios
set /A "changeArList=0"
REM : compute current aspect ratio
call:reduceFraction !scrWidth! !scrHeight! sWr sHr
set "msg="DESIRED_ASPECT_RATIO=!sWr!-!sHr!=!sWr!/!sHr!""
type !logFile! | find /I !msg! > NUL 2>&1 && goto:getArList
REM : will force BatchFw to complete GFX packs/presets
set /A "changeArList=1"
call:log2HostFile !msg!
:getArList
REM : get the users list
set "ARLIST=EMPTY"
REM : search in all Host_*.log
set "pat="!BFW_LOGS:"=!\Host_*.log""
for /F "delims=~" %%i in ('dir /S /B !pat! 2^>NUL') do (
set "currentLogFile="%%i""
REM : get aspect ratio to produce from HOSTNAME.log (asked during setup)
for /F "tokens=2 delims=~=" %%j in ('type !currentLogFile! ^| find /I "DESIRED_ASPECT_RATIO" 2^>NUL') do (
REM : add to the list if not already present
if not ["!ARLIST!"] == [""] echo !ARLIST! | find /V "%%j" > NUL 2>&1 && (
set "ARLIST=%%j !ARLIST!"
REM : will force BatchFw to complete GFX packs/presets
set /A "changeArList=1"
)
if ["!ARLIST!"] == [""] set "ARLIST=%%j !ARLIST!"
)
)
set "ARLIST=!ARLIST:EMPTY=!"
echo.
echo Aspect ratios already defined in BatchFW for all hosts you already used: !ARLIST!
echo.
call:getUserInput "Change this list? (y = add an aspect ratio or define a custom one, n = default in 20s)" "n,y" ANSWER 20
if [!ANSWER!] == ["n"] goto:askScreenMode
echo ---------------------------------------------------------
echo Choose your display ratio ^(for extra graphic packs^) ^:
echo.
echo ^(1^)^: custom one ^(define it^)
echo ^(2^)^: 4^/3
echo ^(3^)^: 16^/9 ^(missing resolutions^) standard HDTV
echo ^(4^)^: 21^/9
echo ^(5^)^: 21^/9 UltraWide 2^.37^:1 ^(2560x1080 = 64^/27^)
echo ^(6^)^: 21^/9 UltraWide 2^.4^:1 ^(1920x900 = 32^/15^)
echo ^(7^)^: 21^/9 UltraWide 2^.13^:1 ^(1920x800 = 12^/5^)
echo ^(8^)^: TV Flat 1^.85^:1 ^(1998x1080 = 37^/20^)
echo ^(9^)^: TV Scope 2^.39^:1 ^(2048x858 = 1024^/429^)
echo ^(10^)^: TV Full Container (DCI) 1^.89^:1 ^(2048x1080 = 256^/135^)
echo ^(c^)^: cancel
echo ---------------------------------------------------------
:askRatioAgain
set /P "ANSWER=Enter your choice: "
if not ["!ANSWER!"] == ["c"] (
if ["!ANSWER!"] == ["1"] (
:getcustomAr
echo.
echo You can enter a directly a target resolution if you don^'t know
echo the reduced ratio^.
echo.
set /P "widthRead=Please enter width : "
set /P "heightRead=Please enter height : "
echo.
REM : compute current aspect ratio
call:reduceFraction !widthRead! !heightRead! width height
choice /C ny /N /M "Define !width!/!height! as aspect ratio ? (y,n): "
if !ERRORLEVEL! EQU 1 goto:getcustomAr
set /P "desc=Please enter a description for this setting : "
call:secureStringForDos !desc! desc > NUL 2>&1
set "desc=!desc:"=!"
set "msg="DESIRED_ASPECT_RATIO=!width!-!height!=!desc!""
goto:anotherRatio
)
if ["!ANSWER!"] == ["2"] (
set "msg="DESIRED_ASPECT_RATIO=4-3=4/3""
goto:anotherRatio
)
if ["!ANSWER!"] == ["3"] (
set "msg="DESIRED_ASPECT_RATIO=16-9=16/9""
goto:anotherRatio
)
if ["!ANSWER!"] == ["4"] (
set "msg="DESIRED_ASPECT_RATIO=21-9=21/9""
goto:anotherRatio
)
if ["!ANSWER!"] == ["5"] (
set "msg="DESIRED_ASPECT_RATIO=64-27=21/9 UltraWide 2.37:1""
goto:anotherRatio
)
if ["!ANSWER!"] == ["6"] (
set "msg="DESIRED_ASPECT_RATIO=32-15=21/9 UltraWide 2.4:1""
goto:anotherRatio
)
if ["!ANSWER!"] == ["7"] (
set "msg="DESIRED_ASPECT_RATIO=12-15=21/9 UltraWide 2.13:1""
goto:anotherRatio
)
if ["!ANSWER!"] == ["8"] (
set "msg="DESIRED_ASPECT_RATIO=37-20=TV Flat 1.85:1""
goto:anotherRatio
)
if ["!ANSWER!"] == ["9"] (
set "msg="DESIRED_ASPECT_RATIO=1024-429=TV Scope 2.39:1""
goto:anotherRatio
)
if ["!ANSWER!"] == ["10"] (
set "msg="DESIRED_ASPECT_RATIO=256-135=TV DCI 1.89:1""
goto:anotherRatio
)
goto:askRatioAgain
) else (
goto:askScreenMode
)
:anotherRatio
type !logFile! | find /I !msg! > NUL 2>&1 && goto:getAnotherRatio
set /A "changeArList=1"
call:log2HostFile !msg!
:getAnotherRatio
choice /C yn /N /M "Add another ratio? (y,n): "
if !ERRORLEVEL! EQU 1 goto:askRatioAgain
:askScreenMode
echo ---------------------------------------------------------
REM : flush logFile of SCREEN_MODE
call:cleanHostLogFile SCREEN_MODE
choice /C yn /N /M "Do you want to launch CEMU in fullscreen? (y,n):"
if !ERRORLEVEL! EQU 1 goto:updateGfxPacksFolder
set "msg="SCREEN_MODE=windowed""
call:log2HostFile !msg!
:updateGfxPacksFolder
set "BFW_GP_FOLDER="!GAMES_FOLDER:"=!\_BatchFw_Graphic_Packs""
REM : check if GAMES_FOLDER\_BatchFw_Graphic_Packs exist
if not exist !BFW_GP_FOLDER! mkdir !BFW_GP_FOLDER! > NUL 2>&1
REM : check if an internet connection is active
if ["!ACTIVE_ADAPTER!"] == ["NONE"] (
set "ACTIVE_ADAPTER=NOT_FOUND"
for /F "tokens=1 delims=~=" %%f in ('wmic nic where "NetConnectionStatus=2" get NetConnectionID /value 2^>NUL ^| find "="') do set "ACTIVE_ADAPTER=%%f"
)
if ["!ACTIVE_ADAPTER!"] == ["NOT_FOUND"] goto:extractlgfxp
echo ---------------------------------------------------------
echo Checking latest graphics packs^'update
REM : update graphic packs
set "ugp="!BFW_PATH:"=!\tools\updateGraphicPacksFolder.bat""
call !ugp!
set /A "cr=!ERRORLEVEL!"
REM : if user cancelled the update
if !cr! EQU 2 if not exist !BFW_GP_FOLDER! goto:beginExtraction
REM : here ["!ACTIVE_ADAPTER!"] != ["NOT_FOUND"]
set "glogFile="!BFW_PATH:"=!\logs\gamesLibrary.log""
if exist !glogFile! if !changeArList! EQU 1 (
REM : clean all entries in glogFile to force bathFw to complete
REM : GFX packs on next launch
call:cleanGameLibFile "version=graphicPacks"
)
if !cr! EQU 0 goto:getUserMode
:extractlgfxp
if !changeArList! EQU 1 goto:beginExtraction
if %QUIET_MODE% EQU 1 goto:getUserMode
:beginExtraction
REM : first launch of setup.bat
if exist !BFW_GP_FOLDER! goto:getUserMode
mkdir !BFW_GP_FOLDER! > NUL 2>&1
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo Extracting embeded graphics packs^.^.^.
echo ---------------------------------------------------------
REM : extract embeded packs
set "rarFile="!BFW_RESOURCES_PATH:"=!\GFX_Packs.rar""
wscript /nologo !StartHiddenWait! !rarExe! x -o+ -inul -w!BFW_LOGS! !rarFile! !BFW_GP_FOLDER! > NUL 2>&1
set /A "cr=!ERRORLEVEL!"
if !cr! GTR 1 (
echo ERROR while extracting GFX_Packs^.rar^, exiting 1
pause
exit /b 1
)
echo ^> Graphic packs installed from archive
REM : get users
:getUserMode
REM : rename GFX folders that contains forbiden characters : & ! . ( )
wscript /nologo !StartHidden! !brcPath! /DIR^:!BFW_GP_FOLDER! /REPLACECI^:^^!^:# /REPLACECI^:^^^&^: /REPLACECI^:^^.^: /REPLACECI^:^^(^:[ /REPLACECI^:^^)^:] /EXECUTE
REM : by default: create shortcuts
echo ---------------------------------------------------------
REM : get the users list
set "usersList=EMPTY"
for /F "tokens=2 delims=~=" %%i in ('type !logFile! ^| find "USER_REGISTERED" 2^>NUL') do set "usersList=!usersList! [%%i]"
if not ["!usersList!"] == ["EMPTY"] goto:handleUsers
choice /C ny /N /M "Do you want to add more than one user? (y,n):"
if !ERRORLEVEL! EQU 1 (
set "msg="USER_REGISTERED=!USERNAME!""
call:log2HostFile !msg!
goto:getSoftware
)
:handleUsers
if ["!usersList!"] == ["EMPTY"] goto:getUsers
set "usersList=!usersList:EMPTY=!"
echo Users already registered in BatchFW: !usersList!
call:getUserInput "Change this list (y,n = default in 20s)? " "n,y" ANSWER 20
if [!ANSWER!] == ["n"] goto:getSoftware
REM : flush logFile of USER_REGISTERED
for /F "tokens=2 delims=~=" %%i in ('type !logFile! ^| find "USER_REGISTERED" 2^>NUL') do call:cleanHostLogFile USER_REGISTERED
REM : Get BatchFw's users registered
set /A "alreadyAsked=0"
:getUsers
if !alreadyAsked! EQU 1 goto:batchFwUsers
:useWiiU
echo.
call:getUserInput "Do you want to use your Wii-U to create BatchFw's users (y,n = default in 20s)? " "n,y" ANSWER 20
echo.
if [!ANSWER!] == ["n"] set /A "alreadyAsked=1" && goto:batchFwUsers
echo.
echo You can use your Wii-U accounts to create BatchFw^'users
echo list and get the files needed to play online^.
echo For that^, you need to had dumped your NAND^.
echo.
if not exist !BFW_WIIU_FOLDER! (
choice /C yn /N /M "Do you need to format a SDCard with homebrew apps on? (y,n):"
if !ERRORLEVEL! EQU 1 wscript /nologo !StartWait! !createWiiuSDcard!
echo.
)
if !NB_GAMES_VALID! NEQ 0 (
choice /C yn /N /M "Continue and create users' list from your Wii-U? (y,n -> enter users manually):"
echo.
if !ERRORLEVEL! EQU 2 set /A "alreadyAsked=1" && goto:batchFwUsers
)
echo On your Wii-U^, you need to ^:
echo - disable the sleeping^/shutdown features
echo - launch WiiU FTP Server
echo - get the IP adress displayed on Wii-U gamepad
echo.
REM : get online files and accounts
pushd !BFW_TOOLS_PATH!
set "tobeLaunch="!BFW_TOOLS_PATH:"=!\getWiiuOnlineFiles.bat""
call !tobeLaunch! -wiiuAccounts
set /A "cr=!ERRORLEVEL!"
pushd !GAMES_FOLDER!
if !cr! NEQ 0 (
echo.
echo Fail to get users from wiiU ^!
goto:handleUsers
)
echo.
if !NB_GAMES_VALID! EQU 0 (
echo Launching dumping games^.^.^.
REM : launch dumping games script
wscript /nologo !Start! !dumpGames!
echo When finished^, relaunch setup^.bat
timeout /T 6 > NUL 2>&1
exit 15
) else (
choice /C yn /N /M "Do you want to import some saves from your WII-U now? (y,n):"
if !ERRORLEVEL! EQU 2 goto:getSoftware
)
echo.
echo BatchFw need to take a snapshot of your Wii-U to
echo will list games^, saves^, updates and DLC
echo precising where they are installed ^(mlc or usb^)
echo.
pushd !BFW_TOOLS_PATH!
set "tobeLaunch="!BFW_TOOLS_PATH:"=!\scanWiiU.bat""
wscript /nologo !StartWait! !tobeLaunch!
echo.
echo Now getting your wii-U saves^.^.^.
echo.
set "tobeLaunch="!BFW_TOOLS_PATH:"=!\importWiiuSaves.bat""
wscript /nologo !StartWait! !tobeLaunch!
pushd !GAMES_FOLDER!
goto:getSoftware
:batchFwUsers
set /P "input=Please enter BatchFw's user name : "
call:secureUserNameForBfw "!input!" safeInput
if !ERRORLEVEL! NEQ 0 (
echo ^~^, ^* or ^= are not allowed characters ^!
echo Please remove them
goto:getUsers
)
if not ["!safeInput!"] == ["!input!"] (
echo Some unhandled characters were found ^!
echo ^^ ^| ^< ^> ^" ^: ^/ ^\ ^? ^. ^! ^& %%
echo list = ^^ ^| ^< ^> ^" ^: ^/ ^\ ^? ^. ^! ^& %%
choice /C yn /N /M "Use !safeInput! instead ? (y,n): "
if !ERRORLEVEL! EQU 2 goto:getUsers
)
set "user="!safeInput!""
set "msg="USER_REGISTERED=!user:"=!""
call:log2HostFile !msg!
choice /C yn /N /M "Add another user? (y,n): "
if !ERRORLEVEL! EQU 1 goto:getUsers
:getSoftware
echo ---------------------------------------------------------
REM : get the software list
set "softwareList=EMPTY"
for /F "tokens=2 delims=~@" %%i in ('type !logFile! ^| find "TO_BE_LAUNCHED" 2^>NUL') do (
set "command=%%i"
call:isSoftwareValid "!command!" program valid
if !valid! EQU 1 (
set "softwareList=!softwareList! !program!"
) else (
call:cleanHostLogFile !program:"='!
)
)
if not ["!softwareList!"] == ["EMPTY"] goto:handleSoftware
echo Do you want BatchFw to launch a third party software before
echo launching CEMU^?
echo ^(E^.G^. DS4Windows^, wiimoteHook^, cemuGyro^, a speed hack^.^.^.^)
echo.
echo They will be launched in the order you will enter here^.
echo.
choice /C ny /N /M "Register a third party software? (y,n): "
if !ERRORLEVEL! EQU 1 goto:askExtMlC01Folders
echo.
:handleSoftware
if ["!softwareList!"] == ["EMPTY"] goto:askS
set "softwareList=!softwareList:EMPTY=!"
echo Software already registered in BatchFW: !softwareList!
choice /C ny /N /M "Change this list? (y,n) "
if !ERRORLEVEL! EQU 1 goto:askExtMlC01Folders
REM : flush logFile of TO_BE_LAUNCHED
call:cleanHostLogFile TO_BE_LAUNCHED
echo ---------------------------------------------------------
choice /C ny /N /M "Add a 3rd party software? (y,n): "
if !ERRORLEVEL! EQU 1 goto:askExtMlC01Folders
:askS
echo ---------------------------------------------------------
choice /C ny /N /M "Do you need to enter arguments for the 3rd party software? (y,n): "
if !ERRORLEVEL! EQU 2 goto:askSpath
REM : browse to the file
:browse3rdP
for /F %%b in ('cscript /nologo !browseFile! "Please browse to 3rd party program"') do set "file=%%b" && set "spath=!file:?= !"
if [!spath!] == ["NONE"] (
choice /C yn /N /M "No item selected, do you wish to cancel (y, n)? : "
if !ERRORLEVEL! EQU 1 goto:askExtMlC01Folders
goto:browse3rdP
)
goto:reg3rdPartySotware
:askSpath
echo Enter full paths for the software and its arguments
echo ALL SURROUNDED by double quotes^.
set /P "spath=Enter the full command line: "
REM : resolve venv for search
for /F "tokens=1 delims=~'" %%j in ("!spath!") do set "program="%%j""
if not exist !program! (
echo !spath! is not valid ^!
goto:askSpath
)
:reg3rdPartySotware
set "spath=!spath:"='!"
set "msg=TO_BE_LAUNCHED@!spath!"
choice /C ny /N /M "Do you want BatchFw to close it after Cemu stops? (y,n) "
if !ERRORLEVEL! EQU 1 set "msg="!msg!@N""
if !ERRORLEVEL! EQU 2 set "msg="!msg!@Y""
call:log2HostFile !msg!
set "name="NONE""
set "program="NONE""
set "firstArg="NONE""
for /F "tokens=1 delims=~'" %%j in ("!spath!") do set "program="%%j""
for /F "delims=~" %%i in (!program!) do set "name=%%~nxi"
set "icoFile=!name:.exe=.ico!"
set "icoPath="!BFW_RESOURCES_PATH:"=!\icons\!icoFile!""
if not exist !icoPath! call !quick_Any2Ico! "-res=!program:"=!" "-icon=!icoPath:"=!" -formats=512
choice /C yn /N /M "Add another third party software? (y,n): "
if !ERRORLEVEL! EQU 1 goto:askSpath
:askExtMlC01Folders
set /A "useMlcFolderFlag=0"
if %nbArgs% EQU 0 if !QUIET_MODE! EQU 0 (
echo ---------------------------------------------------------
choice /C ny /N /M "Do you use an/some external mlc01 folder(s) you wish to import? (y,n): "
if !ERRORLEVEL! EQU 1 goto:getOuptutsType
set "tmpFile="!BFW_PATH:"=!\doc\mlc01data.txt""
wscript /nologo !Start! "%windir%\System32\notepad.exe" !tmpFile!
echo.
echo If you have defined more than one user^, you^'ll need to
echo define which user^'s save is it.
echo.
:getExtMlc01
set "script="!BFW_TOOLS_PATH:"=!\moveMlc01DataForAllGames.bat""
choice /C mc /CS /N /M "Move (m) or copy (c) data?"
set /A "cr=!ERRORLEVEL!"
if !cr! EQU 2 set "script="!BFW_TOOLS_PATH:"=!\copyMlc01DataForAllGames.bat""
wscript /nologo !StartWait! !script!
choice /C yn /N /M "Add another external mlc01 folder? (y,n): "
if !ERRORLEVEL! EQU 1 goto:getExtMlc01
echo ^> Externals mlc01 data was imported^!
echo.
echo Next time use the shortcuts in
echo Wii-U Games^\_BatchFw^\Tools^\Mlc01 folder handling
echo and^/or
echo Wii-U Games^\_BatchFw^\Tools^\Games^'s saves to import
echo only save for a user from a ml01 folder
echo.
pause
set /A "useMlcFolderFlag=1"
)
:getOuptutsType
if %QUIET_MODE% EQU 0 if !NB_GAMES_VALID! EQU 0 (
echo No loadiines games^(^*^.rpx^) founds under !GAMES_FOLDER!^!
echo Please extract BatchFw in your loadiines games^' folder