forked from GenesisFR/RegPatches
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Reg_Patch_BGE.bat
124 lines (93 loc) · 3.09 KB
/
Reg_Patch_BGE.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
@echo off
@setlocal enableextensions
title Reg Patcher for Beyond Good and Evil by Genesis (v1.0)
rem Checking if run from Linux
if defined WINEPREFIX goto init
rem https://ss64.com/vb/syntax-elevate.html
rem Restart the script as admin if it wasn't the case already
echo Checking if the script is run as admin...
fsutil dirty query %SYSTEMDRIVE% > nul
if %ERRORLEVEL%% == 0 (
echo OK
) else (
echo ERROR: admin rights not detected.
echo.
echo The script will now restart as admin.
echo set UAC = CreateObject^("Shell.Application"^) > "%TEMP%\ElevateMe.vbs"
echo UAC.ShellExecute """%~f0""", "%*", "", "runas", 1 >> "%TEMP%\ElevateMe.vbs"
"%TEMP%\ElevateMe.vbs"
del "%TEMP%\ElevateMe.vbs"
exit /B
)
echo.
:init
rem https://www.codeproject.com/Tips/119828/Running-a-bat-file-as-administrator-Correcting-cur
rem Correct current directory when a script is run as admin
@cd /d "%~dp0"
rem https://alt.msdos.batch.narkive.com/LNB84uUc/replace-all-backslashes-in-a-string-with-double-backslash
rem Double backslashes in the current directory path
set _CD_DOUBLE_BACKSLASH=%CD:\=\\%
rem https://ss64.com/nt/syntax-64bit.html
echo Detecting OS bitness...
set _OS_BITNESS=64
set _PROGRAM_FILES=%PROGRAMFILES(X86)%
if %PROCESSOR_ARCHITECTURE% == x86 (
if not defined PROCESSOR_ARCHITEW6432 (
set _OS_BITNESS=32
set _PROGRAM_FILES=%PROGRAMFILES%
)
)
echo Your OS is %_OS_BITNESS%-bit.
echo.
rem Shortcuts for registry keys
set _BGE=HKLM\Software\ubisoft\Beyond Good ^& Evil
set _BGE_EXPORT=HKEY_LOCAL_MACHINE\Software\Wow6432Node\ubisoft\Beyond Good ^^^& Evil
set _REG_ARG=/reg:32
set _REG_FILE=%~n0.reg
rem WOW6432Node and /reg:32 aren't present on 32-bit systems
if %_OS_BITNESS% == 32 (
set _BGE_EXPORT=HKEY_LOCAL_MACHINE\Software\ubisoft\Beyond Good ^^^& Evil
set _REG_ARG=
)
if defined WINEPREFIX (
set _BGE_EXPORT=HKEY_LOCAL_MACHINE\Software\ubisoft\Beyond Good ^^^& Evil
set _REG_ARG=
)
rem Selection menu
echo Please make a selection:
echo.
echo 1. Add registry entries for Beyond Good and Evil (needed for SettingsApplication.exe)
echo 2. Export registry entries to a REG file (useful on Linux)
echo 3. Remove registry entries
echo 4. Exit
echo.
choice /C:1234 /N
if %ERRORLEVEL% == 1 goto BGE
if %ERRORLEVEL% == 2 goto export
if %ERRORLEVEL% == 3 goto cleanup
if %ERRORLEVEL% == 4 exit /B
:BGE
echo Adding registry entries for Beyond Good and Evil...
REG ADD "%_BGE%" /v "Install Path" /t REG_SZ /d "%CD%" /f %_REG_ARG% > nul
echo DONE
goto end
:export
echo REGEDIT4> %_REG_FILE%
echo.>> %_REG_FILE%
echo Exporting registry entries for Beyond Good and Evil...
echo [%_BGE_EXPORT%]>> %_REG_FILE%
echo "Install Path"="%_CD_DOUBLE_BACKSLASH%">> %_REG_FILE%
echo.>> %_REG_FILE%
echo DONE
echo.
echo A new file called "%_REG_FILE%" has been created in the current directory.
goto end
:cleanup
echo Removing registry entries for Beyond Good and Evil...
REG DELETE "%_BGE%" /f %_REG_ARG% > nul
echo DONE
goto end
:end
echo.
pause
endlocal