@echo off & setlocal enabledelayedexpansion
set "t=%temp%\patch_temp.txt"

for %%f in (RdUninst.dat Setup.dat RDIF1087.INF) do (
	ren %%f %%f.UCS
	type %%f.UCS >%%f
	del %%f.UCS
	if exist "%t%" del "%t%"
	for /f "delims=" %%i in ('findstr /n "^" "%%f"') do set "Line=%%i" & call :ProcessLine
	move "%t%" "%%f"
)
goto :eof

:ProcessLine
set "Line=!Line:"=""!"
for /f "tokens=1* delims=:" %%a in ("%Line%") do set "L=%%b"
if not defined L >>"%t%" echo\& goto :eof
set "L=!L:""="!"
for /f "tokens=1-2 delims=;" %%s in ("JUNO Series;XV-5050") do set "L=!L:%%s=%%t!"
for /f "tokens=1-2 delims=;" %%s in ("JUNO;XV-5050") do set "L=!L:%%s=%%t!"
for /f "tokens=1-2 delims=;" %%s in ("00F8;0012") do set "L=!L:%%s=%%t!"
for /f "tokens=1-2 delims=;" %%s in ("00F9;0013") do set "L=!L:%%s=%%t!"
echo %L% >nul
if errorlevel 1 set "L=!L:&=^&!"
>>"%t%" echo %L%
echo %L% | find "%%RDID0087DeviceDesc%%=">nul && set "DD=%L%"
echo %L% | find "[Roland.NTx86.7]">nul && >>"%t%" echo %DD%
echo %L% | find "[Roland.NTamd64.7]">nul && >>"%t%" echo %DD%
goto :eof
