11@ echo off
2-
32setlocal enabledelayedexpansion
43
54REM BG EE: Baldur.exe
@@ -12,55 +11,80 @@ REM IWD: IDMain.exe
1211REM Torment: Torment.exe
1312
1413REM Check for original executables (BGMain2.exe is for BG and BGMain.exe is for BG2)
15- if exist " BGMain2.exe" (set " TARGET_EXE=BGMain2.exe" & goto :next)
16- if exist " BGMain.exe" (set " TARGET_EXE=BGMain.exe" & goto :next)
17- if exist " IDMain.exe" (set " TARGET_EXE=IDMain.exe" & goto :next)
18- if exist " Torment.exe" (set " TARGET_EXE=Torment.exe" & goto :next)
14+ if exist " BGMain2.exe" (
15+ set " TARGET_EXE = BGMain2.exe"
16+ goto :next
17+ )
18+ if exist " BGMain.exe" (
19+ set " TARGET_EXE = BGMain.exe"
20+ goto :next
21+ )
22+ if exist " IDMain.exe" (
23+ set " TARGET_EXE = IDMain.exe"
24+ goto :next
25+ )
26+ if exist " Torment.exe" (
27+ set " TARGET_EXE = Torment.exe"
28+ goto :next
29+ )
1930
2031REM Check for EE executables
21- if exist " Baldur.exe" (set " TARGET_EXE=Baldur.exe" & goto :next)
22- if exist " Baldur2.exe" (set " TARGET_EXE=Baldur2.exe" & goto :next)
23- if exist " Icewind.exe" (set " TARGET_EXE=Icewind.exe" & goto :next)
24- if exist " Torment.exe" (set " TARGET_EXE=Torment.exe" & goto :next)
32+ if exist " Baldur.exe" (
33+ set " TARGET_EXE = Baldur.exe"
34+ goto :next
35+ )
36+ if exist " Baldur2.exe" (
37+ set " TARGET_EXE = Baldur2.exe"
38+ goto :next
39+ )
40+ if exist " Icewind.exe" (
41+ set " TARGET_EXE = Icewind.exe"
42+ goto :next
43+ )
44+ if exist " Torment.exe" (
45+ set " TARGET_EXE = Torment.exe"
46+ goto :next
47+ )
2548
2649echo No matching executable found. Exiting...
2750exit /b 1
2851
2952:next
3053
3154REM Check if the executable is 32-bit
32- for /f %%G in ('powershell -NoProfile -Command " (get-content '%TARGET_EXE% ' -totalcount 50) | select-string -Pattern 'PE..L' -Quiet" ') do ( set " IS32EXE = %%G " )
55+ for /f %%G in ('powershell -NoProfile -Command " (get-content '%TARGET_EXE% ' -totalcount 50) | select-string -Pattern 'PE..L' -Quiet" ') do (
56+ set " IS32EXE = %%G "
57+ )
3358REM Check if the executable is 64-bit
34- for /f %%G in ('powershell -NoProfile -Command " (get-content '%TARGET_EXE% ' -totalcount 50) | select-string -Pattern 'PE..d' -Quiet" ') do ( set " IS64EXE = %%G " )
59+ for /f %%G in ('powershell -NoProfile -Command " (get-content '%TARGET_EXE% ' -totalcount 50) | select-string -Pattern 'PE..d' -Quiet" ') do (
60+ set " IS64EXE = %%G "
61+ )
3562
3663REM Check for 32-bit target executable
37- if " % IS32EXE% " == " True" (
64+ if " ! IS32EXE! " == " True" (
3865 set " DLL_NAME = BetterRandom_x86.dll"
3966 set " SETDLL = setdll_x86.exe"
4067 REM Additional actions for 32-bit executable...
4168)
4269
4370REM Check for 64-bit target executable
44- if " % IS64EXE% " == " True" (
71+ if " ! IS64EXE! " == " True" (
4572 set " DLL_NAME = BetterRandom_x64.dll"
4673 set " SETDLL = setdll_x64.exe"
4774 REM Additional actions for 64-bit executable...
4875)
4976
50-
5177REM Prompt user for action
5278echo 1. Add BetterRandom library to %TARGET_EXE%
5379echo 2. Remove BetterRandom library from %TARGET_EXE%
5480set /p " ACTION = Enter action number (1 or 2): "
5581
56-
5782REM Process user's choice
5883if " !ACTION! " == " 1" (
5984 REM Inject the BetterRandom library using setdll.exe
6085 %SETDLL% /d:%DLL_NAME% %TARGET_EXE%
6186) else if " !ACTION! " == " 2" (
62- REM Remove the BetterRandom libary using setdll.exe
63- echo %SETDLL%
87+ REM Remove the BetterRandom library using setdll.exe
6488 %SETDLL% /r %TARGET_EXE%
6589) else (
6690 echo Invalid action number. Exiting...
0 commit comments