@echo off
cls
:start
echo.
echo 1. Install Dolby Home Theater v4
echo 2. Install Dolby Advanced Audio v2
echo 3. Remove Dolby Home Theater v4 / Advanced Audio v2
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 pcee4.exe
taskkill /f /im pcee4d.exe
taskkill /f /im pcee4e.exe
taskkill /f /im pcee4l.exe
net stop audiosrv
takeown /f "%dest%\EEA%OS%A.dll"
takeown /f "%dest%\EED%OS%A.dll"
takeown /f "%dest%\EEG%OS%A.dll"
takeown /f "%dest%\EEL%OS%A.dll"
takeown /f "%dest%\EEP%OS%A.dll"
cacls "%dest%\EEA%OS%A.dll" /e /p administrators:f
cacls "%dest%\EED%OS%A.dll" /e /p administrators:f
cacls "%dest%\EEG%OS%A.dll" /e /p administrators:f
cacls "%dest%\EEL%OS%A.dll" /e /p administrators:f
cacls "%dest%\EEP%OS%A.dll" /e /p administrators:f
copy /y "%~dp0EEA%OS%A.dll" %dest%
copy /y "%~dp0EED%OS%A.dll" %dest%
copy /y "%~dp0EEG%OS%A.dll" %dest%
copy /y "%~dp0EEL%OS%A.dll" %dest%
copy /y "%~dp0EEP%OS%A.dll" %dest%
regsvr32 /s EEA%OS%A.dll
regsvr32 /s EED%OS%A.dll
regsvr32 /s EEG%OS%A.dll
regsvr32 /s EEL%OS%A.dll
regsvr32 /s EEP%OS%A.dll
net start audiosrv
if %editon%==ddpht (
regedit /s "%~dp0DolbyHomeTheater.reg"
msiexec /i "%~dp0DolbyHomeTheater.msi" /qn
)
if %editon%==ddpaa (
regedit /s "%~dp0DolbyAdvancedAudio.reg"
msiexec /i "%~dp0DolbyAdvancedAudio.msi" /qn
)
goto start

:remove
taskkill /f /im pcee4.exe
taskkill /f /im pcee4d.exe
taskkill /f /im pcee4e.exe
taskkill /f /im pcee4l.exe
net stop audiosrv
takeown /f "%dest%\EEA%OS%A.dll"
takeown /f "%dest%\EED%OS%A.dll"
takeown /f "%dest%\EEG%OS%A.dll"
takeown /f "%dest%\EEL%OS%A.dll"
takeown /f "%dest%\EEP%OS%A.dll"
cacls "%dest%\EEA%OS%A.dll" /e /p administrators:f
cacls "%dest%\EED%OS%A.dll" /e /p administrators:f
cacls "%dest%\EEG%OS%A.dll" /e /p administrators:f
cacls "%dest%\EEL%OS%A.dll" /e /p administrators:f
cacls "%dest%\EEP%OS%A.dll" /e /p administrators:f
copy /y "%~dp0EEA%OS%A.dll" %dest%
copy /y "%~dp0EED%OS%A.dll" %dest%
copy /y "%~dp0EEG%OS%A.dll" %dest%
copy /y "%~dp0EEL%OS%A.dll" %dest%
copy /y "%~dp0EEP%OS%A.dll" %dest%
regsvr32 /s /u EEA%OS%A.dll
regsvr32 /s /u EED%OS%A.dll
regsvr32 /s /u EEG%OS%A.dll
regsvr32 /s /u EEL%OS%A.dll
regsvr32 /s /u EEP%OS%A.dll
del /f "%dest%\EEA%OS%A.dll"
del /f "%dest%\EED%OS%A.dll"
del /f "%dest%\EEG%OS%A.dll"
del /f "%dest%\EEL%OS%A.dll"
del /f "%dest%\EEP%OS%A.dll"
msiexec /x{B9E70C7A-9F85-4A39-A4A3-BFA3C3BF7613} /qn
msiexec /x{B26438B4-BF51-49C3-9567-7F14A5E40CB9} /qn
reg delete HKLM\SOFTWARE\Dolby\PCEE4\StaticKeys /f
reg delete HKLM\SOFTWARE\Dolby\PCEE4\DynamicKeys /f
net start audiosrv
goto start