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

:install
net stop "Dolby DAX2 API Service"
taskkill /f /im DolbyDax2Acknowledgement.exe
taskkill /f /im DolbyDAX2Demo.exe
taskkill /f /im DolbyDAX2DesktopUI.exe
taskkill /f /im DolbyDax2Launcher.exe
taskkill /f /im DolbyDAX2Toast.exe
taskkill /f /im DolbyDAX2TrayIcon.exe
net stop audiosrv
takeown /f "%dest%\DolbyDAX2APOProp.dll"
takeown /f "%dest%\DolbyDAX2APOv201.dll"
takeown /f "%dest%\DolbyDAX2APOv211.dll"
takeown /f "%dest%\DolbyDAX2APOvlldp.dll"
takeown /f "%dest%\HiFiDAX2API.dll"
takeown /f "%dest%\HiFiDAX2APIPCLL.dll"
cacls "%dest%\DolbyDAX2APOProp.dll" /e /p administrators:f
cacls "%dest%\DolbyDAX2APOv201.dll" /e /p administrators:f
cacls "%dest%\DolbyDAX2APOv211.dll" /e /p administrators:f
cacls "%dest%\DolbyDAX2APOvlldp.dll" /e /p administrators:f
cacls "%dest%\HiFiDAX2API.dll" /e /p administrators:f
cacls "%dest%\HiFiDAX2APIPCLL.dll /e /p administrators:f
copy /y "%filepath%\DolbyDAX2APOProp.dll" %dest%
copy /y "%filepath%\DolbyDAX2APOv201.dll" %dest%
copy /y "%filepath%\DolbyDAX2APOv211.dll" %dest%
copy /y "%filepath%\DolbyDAX2APOvlldp.dll" %dest%
copy /y "%filepath%\HiFiDAX2API.dll" %dest%
copy /y "%filepath%\HiFiDAX2APIPCLL.dll" %dest%
regsvr32 /s DolbyDAX2APOProp.dll
regsvr32 /s DolbyDAX2APOv201.dll
regsvr32 /s DolbyDAX2APOv211.dll
regsvr32 /s DolbyDAX2APOvlldp.dll
regsvr32 /s HiFiDAX2API.dll
regsvr32 /s HiFiDAX2APIPCLL.dll
md "%windir%\system32\DAX2"
copy /y "%filepath%\DAX2.sdf" %dest%\DAX2
if %OS%==64 (
msiexec /i "%filepath%\dax2_api_release_x64.msi" /qn
"%filepath%\UpdateDax2Db.exe"
msiexec /i "%filepath%\dax2_app_release_x64.msi" /qn
)
if %OS%==32 (
msiexec /i "%filepath%\dax2_api_release_x86.msi" /qn
"%filepath%\UpdateDax2Db.exe"
msiexec /i "%filepath%\dax2_app_release_x86.msi" /qn
)
net start audiosrv
goto start

:remove
net stop "Dolby DAX2 API Service"
taskkill /f /im DolbyDax2Acknowledgement.exe
taskkill /f /im DolbyDAX2Demo.exe
taskkill /f /im DolbyDAX2DesktopUI.exe
taskkill /f /im DolbyDax2Launcher.exe
taskkill /f /im DolbyDAX2Toast.exe
taskkill /f /im DolbyDAX2TrayIcon.exe
net stop audiosrv
takeown /f "%dest%\DolbyDAX2APOProp.dll"
takeown /f "%dest%\DolbyDAX2APOv201.dll"
takeown /f "%dest%\DolbyDAX2APOv211.dll"
takeown /f "%dest%\DolbyDAX2APOvlldp.dll"
takeown /f "%dest%\HiFiDAX2API.dll"
takeown /f "%dest%\HiFiDAX2APIPCLL.dll"
cacls "%dest%\DolbyDAX2APOProp.dll" /e /p administrators:f
cacls "%dest%\DolbyDAX2APOv201.dll" /e /p administrators:f
cacls "%dest%\DolbyDAX2APOv211.dll" /e /p administrators:f
cacls "%dest%\DolbyDAX2APOvlldp.dll" /e /p administrators:f
cacls "%dest%\HiFiDAX2API.dll" /e /p administrators:f
cacls "%dest%\HiFiDAX2APIPCLL.dll /e /p administrators:f
regsvr32 /s /u DolbyDAX2APOProp.dll
regsvr32 /s /u DolbyDAX2APOv201.dll
regsvr32 /s /u DolbyDAX2APOv211.dll
regsvr32 /s /u DolbyDAX2APOvlldp.dll
regsvr32 /s /u HiFiDAX2API.dll
regsvr32 /s /u HiFiDAX2APIPCLL.dll
del /f "%dest%\DolbyDAX2APOProp.dll"
del /f "%dest%\DolbyDAX2APOv201.dll"
del /f "%dest%\DolbyDAX2APOv211.dll" 
del /f "%dest%\DolbyDAX2APOvlldp.dll"
del /f "%dest%\HiFiDAX2API.dll"
del /f "%dest%\HiFiDAX2APIPCLL.dll"
del /f "%dest%\DAX2\DAX2.sdf" 
if %OS%==64 (
msiexec /x{4A02DCED-C2B0-4DD3-87BD-7D8E68D6AF3C} /qn
msiexec /x{F994125B-7BF5-4A38-A569-82833CEB24DC} /qn
)
if %OS%==32 (
msiexec /x{52575D2D-373D-4E2D-ABD8-AF56AAF17803} /qn
msiexec /x{B2D04867-1EC4-48EF-9FE1-967CE6A2155C} /qn
)
reg delete HKCU\Software\Dolby\DAX2 /f
net start audiosrv
goto start
