@echo off
cls
:start
echo.
echo 1. Install Dolby Digital Plus Home Theater
echo 2. Install Dolby Digital Plus Advanced Audio
echo 3. Remove Dolby Digital Plus
echo 4. Exit
echo.
reg query "HKLM\Hardware\Description\System\CentralProcessor\0" | find /i "x86" > NUL && set OS=32 || set OS=64
set dest=%windir%\system32
set choice=
set /p choice=Type the number:
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='1' (
set editon=ddpht
goto install
)
if '%choice%'=='2' (
set editon=ddpaa
goto install
)
if '%choice%'=='3' goto remove
if '%choice%'=='4' exit
echo "%choice%" is not valid, try again
echo.
goto start

:install
taskkill /f /im ddp.exe
taskkill /f /im ddpd.exe
taskkill /f /im ddpe.exe
taskkill /f /im ddpl.exe
net stop audiosrv
takeown /f "%dest%\DDPA%OS%.dll"
takeown /f "%dest%\DDPD%OS%A.dll"
takeown /f "%dest%\DDPO%OS%A.dll"
takeown /f "%dest%\DDPP%OS%A.dll"
cacls "%dest%\DDPA%OS%.dll" /e /p administrators:f
cacls "%dest%\DDPD%OS%A.dll" /e /p administrators:f
cacls "%dest%\DDPO%OS%A.dll" /e /p administrators:f
cacls "%dest%\DDPP%OS%A.dll" /e /p administrators:f
copy /y "%~dp0DDPA%OS%.dll" %dest%
copy /y "%~dp0DDPD%OS%A.dll" %dest%
copy /y "%~dp0DDPO%OS%A.dll" %dest%
copy /y "%~dp0DDPP%OS%A.dll" %dest%
regsvr32 /s DDPA%OS%.dll
regsvr32 /s DDPD%OS%A.dll
regsvr32 /s DDPO%OS%A.dll
regsvr32 /s DDPP%OS%A.dll
if %OS%==64 (
takeown /f "%dest%\DDPA64F3.dll"
takeown /f "%dest%\DDPD64AF3.dll"
takeown /f "%dest%\DDPO64AF3.dll"
takeown /f "%dest%\DDPP64AF3.dll"
cacls "%dest%\DDPA64F3.dll" /e /p administrators:f
cacls "%dest%\DDPD64AF3.dll" /e /p administrators:f
cacls "%dest%\DDPO64AF3.dll" /e /p administrators:f
cacls "%dest%\DDPP64AF3.dll" /e /p administrators:f
copy /y "%~dp0DDPA64F3.dll" %dest%
copy /y "%~dp0DDPD64AF3.dll" %dest%
copy /y "%~dp0DDPO64AF3.dll" %dest%
copy /y "%~dp0DDPP64AF3.dll" %dest%
regsvr32 /s DDPA64F3.dll
regsvr32 /s DDPD64AF3.dll
regsvr32 /s DDPO64AF3.dll
regsvr32 /s DDPP64AF3.dll
)
net start audiosrv
if %editon%==ddpht (
regedit /s "%~dp0DolbyDigitalPlusHT.reg"
msiexec /i "%~dp0DolbyDigitalPlusHT.msi" /qn
)
if %editon%==ddpaa (
regedit /s "%~dp0DolbyDigitalPlusAA.reg"
msiexec /i "%~dp0DolbyDigitalPlusAA.msi" /qn
)
schtasks /create /tn "CreateDolbySelectorTask" /xml "%~dp0CreateDolbySelectorTask.xml" /f
goto start

:remove
taskkill /f /im ddp.exe
taskkill /f /im ddpd.exe
taskkill /f /im ddpe.exe
taskkill /f /im ddpl.exe
net stop audiosrv
takeown /f "%dest%\DDPA%OS%.dll"
takeown /f "%dest%\DDPD%OS%A.dll"
takeown /f "%dest%\DDPO%OS%A.dll"
takeown /f "%dest%\DDPP%OS%A.dll"
cacls "%dest%\DDPA%OS%.dll" /e /p administrators:f
cacls "%dest%\DDPD%OS%A.dll" /e /p administrators:f
cacls "%dest%\DDPO%OS%A.dll" /e /p administrators:f
cacls "%dest%\DDPP%OS%A.dll" /e /p administrators:f
regsvr32 /s /u DDPA%OS%.dll
regsvr32 /s /u DDPD%OS%A.dll
regsvr32 /s /u DDPO%OS%A.dll
regsvr32 /s /u DDPP%OS%A.dll
del /f "%dest%\DDPA%OS%.dll"
del /f "%dest%\DDPD%OS%A.dll"
del /f "%dest%\DDPO%OS%A.dll"
del /f "%dest%\DDPP%OS%A.dll"
if %OS%==64 (
takeown /f "%dest%\DDPA64F3.dll"
takeown /f "%dest%\DDPD64AF3.dll"
takeown /f "%dest%\DDPO64AF3.dll"
takeown /f "%dest%\DDPP64AF3.dll"
cacls "%dest%\DDPA64F3.dll" /e /p administrators:f
cacls "%dest%\DDPD64AF3.dll" /e /p administrators:f
cacls "%dest%\DDPO64AF3.dll" /e /p administrators:f
cacls "%dest%\DDPP64AF3.dll" /e /p administrators:f
del /f "%dest%\DDPA64F3.dll"
del /f "%dest%\DDPD64AF3.dll"
del /f "%dest%\DDPO64AF3.dll"
del /f "%dest%\DDPP64AF3.dll"
regsvr32 /s /u DDPA64F3.dll
regsvr32 /s /u DDPD64AF3.dll
regsvr32 /s /u DDPO64AF3.dll
regsvr32 /s /u DDPP64AF3.dll
)
msiexec /x{B0BFC63F-EA07-419E-960B-3FB2ED5DD0B2} /qn
msiexec /x{7E3D8FA1-6092-469A-955B-68FC4A2C67CA} /qn
schtasks /delete /tn "CreateDolbySelectorTask" /f
net start audiosrv
goto start
