-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathamdocl.bat
More file actions
179 lines (157 loc) · 4.88 KB
/
amdocl.bat
File metadata and controls
179 lines (157 loc) · 4.88 KB
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
@echo off
cls
echo OpenCL Driver (ICD) Fix for AMD GPUs
echo Original work by Patrick Trumpis (https://github.com/ptrumpis/OpenCL-AMD-GPU)
echo Improvements by TantalusDrive (https://github.com/TantalusDrive)
REM SysWOW64 handling, PATH scan, versioned DLLs, duplicate prevention
echo Inspired by https://stackoverflow.com/a/28407851
echo:
echo:
REM ============================================================
REM Privilege check
REM ============================================================
net session >nul 2>&1
if %errorlevel% neq 0 (
echo Execution stopped
echo =================
echo This script requires administrator rights.
echo Please run it again as administrator.
echo You can right click the file and select 'Run as administrator'
echo:
pause
exit /b 1
)
SETLOCAL EnableDelayedExpansion
SET ROOTKEY64=HKEY_LOCAL_MACHINE\SOFTWARE\Khronos\OpenCL\Vendors
SET ROOTKEY32=HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Khronos\OpenCL\Vendors
echo Currently installed OpenCL Client Drivers - 64bit
echo ==================================================
reg query %ROOTKEY64% >nul 2>&1 && (
for /f "tokens=1,*" %%A in ('reg query %ROOTKEY64%') do echo %%A - %%B
) || echo (none)
echo:
echo Currently installed OpenCL Client Drivers - 32bit
echo ==================================================
reg query %ROOTKEY32% >nul 2>&1 && (
for /f "tokens=1,*" %%A in ('reg query %ROOTKEY32%') do echo %%A - %%B
) || echo (none)
echo:
echo This script will now attempt to find and install unregistered OpenCL AMD drivers (Fast Scan).
set "INPUT="
set /P "INPUT=Do you want to continue? (Y/N): "
if /I "!INPUT!"=="Y" (
echo:
goto :scanFilesFast
) else (
goto :exit
)
:scanFilesFast
echo Running AMD OpenCL Driver Auto Detection
echo ========================================
echo:
echo Scanning '%SYSTEMROOT%\System32' for 'amdocl*.dll' files...
cd /d %SYSTEMROOT%\System32
call :registerMissingClientDriver
echo:
echo Scanning '%SYSTEMROOT%\SysWOW64' for 'amdocl*.dll' files...
cd /d %SYSTEMROOT%\SysWOW64
call :registerMissingClientDriver
echo:
echo Fast Scan complete.
echo:
echo This script will now attempt a Full Scan (PATH).
set "INPUT="
set /P "INPUT=Do you want to continue? (Y/N): "
if /I "!INPUT!"=="Y" (
goto :scanFilesFull
) else (
goto :complete
)
:scanFilesFull
echo Now scanning your PATH for 'amdocl*.dll' files...
echo:
for %%A in ("%path:;=";"%") do (
if "%%~A" neq "" (
if exist "%%~A\" (
pushd "%%~A" >nul 2>&1
if !ERRORLEVEL! == 0 (
call :registerMissingClientDriver
popd
)
)
)
)
echo:
echo Full Scan complete.
echo:
:complete
echo Done.
pause
goto :exit
:exit
exit /b 0
REM ============================================================
REM Register missing client drivers
REM ============================================================
:registerMissingClientDriver
for /r %%f in (amdocl*.dll) do (
set FILE=%%~dpnxf
set NAME=%%~nxf
REM Accept fixed names and versioned variants (only real AMD files)
set "VALID="
if /I "!NAME!"=="amdocl.dll" (
set "VALID=1"
) else if /I "!NAME!"=="amdocl64.dll" (
set "VALID=1"
) else if /I "!NAME!"=="amdocl12cl.dll" (
set "VALID=1"
) else if /I "!NAME!"=="amdocl12cl64.dll" (
set "VALID=1"
) else (
REM Versioned variants used by AMD releases
echo !NAME! | findstr /C:"amdocl64_" >nul && set "VALID=1"
echo !NAME! | findstr /C:"amdocl_" >nul && set "VALID=1"
)
if defined VALID (
echo Found: !FILE!
REM Bitness detection (prefer explicit 64, otherwise default to 32)
if /I "!NAME!"=="amdocl64.dll" (
set "ROOTKEY=!ROOTKEY64!"
) else if /I "!NAME!"=="amdocl12cl64.dll" (
set "ROOTKEY=!ROOTKEY64!"
) else (
echo !NAME! | findstr /C:"amdocl64_" >nul
if !ERRORLEVEL! == 0 (
set "ROOTKEY=!ROOTKEY64!"
) else (
REM Default to 32-bit if not matched above
set "ROOTKEY=!ROOTKEY32!"
)
)
REM Ensure root key exists
reg query !ROOTKEY! >nul 2>&1
if !ERRORLEVEL! neq 0 (
reg add !ROOTKEY! /f >nul 2>&1
if !ERRORLEVEL! == 0 (
echo Added Key: !ROOTKEY!
) else (
echo ERROR: Failed to add key !ROOTKEY!
)
)
REM Register DLL if missing
reg query !ROOTKEY! /v "!FILE!" >nul 2>&1
if !ERRORLEVEL! neq 0 (
reg add !ROOTKEY! /v "!FILE!" /t REG_DWORD /d 0 /f >nul 2>&1
if !ERRORLEVEL! == 0 (
echo Registered: !FILE!
) else (
echo ERROR: Failed to register !FILE!
)
) else (
echo Already present: !FILE!
)
)
REM Reset VALID for next iteration
set "VALID="
)
goto :eof