-
Notifications
You must be signed in to change notification settings - Fork 9
/
d2mxl_dep_reset.bat
159 lines (116 loc) · 4.01 KB
/
d2mxl_dep_reset.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
@ECHO OFF
REM Authors: Ryan Paul
REM Date: 01/18/19
REM Version: 0.1.0
REM Usage: d2mxl_dep_reset.bat
REM Description: Removes any DEP settings for the current Diablo II install path
REM ~ Action List ~
REM 1. Install Path
REM 2. DEP Settings
SETLOCAL EnableDelayedExpansion
SETLOCAL EnableExtensions
REM ~ Privelege Mode Check ~
net session >nul 2>&1
if NOT %errorLevel% == 0 (
CALL :log "Administrative permissions required. Run this batch file as Administrator..."
pause >nul
goto :exitapp
)
REM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
REM Output file
REM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
REM ~ Define output temp file ~
SET "output_file=%tmp%\%~n0.txt"
REM ~ Test for report text file permissions ~
TYPE NUL > "%output_file%"
IF EXIST "%output_file%" (
SET "output_file_exists=TRUE"
) ELSE (
CALL :log "Could not create '%output_file%'^^^! Sending output to console..."
CALL :log_nl
)
REM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
REM 1. Install Path
REM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SET "reg_diabloII=HKEY_CURRENT_USER\Software\Blizzard Entertainment\Diablo II"
REM ~ Check for registry key ~
REG QUERY "%reg_diabloII%" >nul 2>&1
IF %ERRORLEVEL% EQU 0 (
CALL :log "Checking For Installation Path..."
REM ~ Search registry entries ~
FOR /F "tokens=2*" %%a IN ('REG QUERY "%reg_diabloII%" /v "InstallPath"') DO SET "path_d2_install=%%b"
REM ~ Remove trailing backslash ~
IF "!path_d2_install:~-1!" == "\" SET "path_d2_install=!path_d2_install:~0,-1!"
REM ~ Report findings ~
IF "!path_d2_install!" == "" (
CALL :log "Diablo II registry sub-key 'InstallPath' not found^^^!"
GOTO :end
) ELSE (
CALL :log "Entry Exists: '!path_d2_install!'"
)
) ELSE (
CALL :log "Parent 'Diablo II' registry key not found^^^!"
GOTO :end
)
CALL :log_nl
REM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
REM 2. DEP Settings
REM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
REM ~ Config ~
SET "reg_hive[0]=HKCU"
SET "reg_hive[1]=HKLM"
SET "process_name[0]=Diablo II.exe"
SET "process_name[1]=Game.exe"
SET "reg_compat_path=Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers"
SET "dep_deleted=0"
REM ~ For each hive ~
FOR /L %%h IN (0,1,1) DO (
REM ~ For each process ~
FOR /L %%p IN (0,1,1) DO (
REG DELETE "!reg_hive[%%h]!\%reg_compat_path%" /v "%path_d2_install%\!process_name[%%p]!" /f >nul 2>&1
IF !ERRORLEVEL! EQU 0 (
CALL :log "Deleted !reg_hive[%%h]!'s '!process_name[%%p]!' DEP entry"
SET "dep_deleted=1"
)
)
)
IF %dep_deleted% EQU 0 (
CALL :log "No DEP entries found for current installation"
)
CALL :log_nl
CALL :log "Use the Windows DEP dialog to re-add 'Game.exe' and 'Diablo II.exe' to the exception list..."
CALL :log_nl
REM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
REM Show output file, if existing
REM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:end
IF DEFINED output_file_exists (
NOTEPAD %output_file%
) ELSE (
PAUSE
)
REM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
REM End of program
REM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:exitapp
EXIT /B 0
REM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
REM Functions
REM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
REM ~ Function signature: log(str) ~
:log
REM ~ Parens are needed to keep all characters escaped as strings ~
IF DEFINED output_file_exists (
(ECHO "%~1")>>"%output_file%"
) ELSE (
(ECHO "%~1")
)
EXIT /B 0
REM ~ Outputs a newline ~
:log_nl
IF DEFINED output_file_exists (
ECHO\>>"%output_file%"
) ELSE (
ECHO\
)
EXIT /B 0