@echo off
REM In a batch file, the total length of a command line can't contain more than 8191 characters.
setlocal enabledelayedexpansion 
cd /d %~dp0

pnputil /delete-driver ".\SynaAPO\AudioService.inf" /uninstall >nul 2>nul

powershell "Get-PnpDevice -FriendlyName '*audio*'|Select-Object -Property HardwareID">[senary_temp].txt

rem search for models that require oedExtInf
type [senary_temp].txt|findstr /i "1D051382 1B618005 1EC91A07 1EC91A05 1EC91A06"
if !errorlevel!==0 (echo pnputil /add-driver ".\ExtSenary_IntcOED\IntcOED_OemLibPath.inf" /install
					pnputil /add-driver ".\ExtSenary_IntcOED\IntcOED_OemLibPath.inf" /install)

rem withoutUWP, with headset mic Senary APO and PortC Senary APO
type [senary_temp].txt|findstr /i "14F103A2 14F103A0 14F103A1 1E507045 14F10398 14F10393 14F10391 14F11700 14F1038E 10199875 1FDB0001 1019C001 14F10387 14F10385 14F1036B 14F10382 14F10381 1F4CB003 14F10241 14F10352 14F10233 14F1034F 14F1034C 14F1034E 14F1034B 14F10339 14F10334 14F10338 14F10335 14F10333 14F1032D 14F1032C 14F10221 14F10220 1E508034 14F10373 14F10377 14F10361 1E508035 1E508031 278212B1 14F1035E 1E507012 14F1036F 14F1036D 1E508029 1E508028 278212B4 14F10355 14F10362 14F10358 1E508020 14F10238 14F10239 14F10345 1E508018 1E508017 14F10356 14F1032A 05266002 14F10230 14F10341 14F10349 14F10330 14F1034D 14F10336 14F10337 14F10348 14F1033B 14F1033C"
if !errorlevel!==0 goto Install-ATN1

rem withoutUWP, with headset mic Senary APO and Intel dmic Senary APO
type [senary_temp].txt|findstr /i "1B618003 1B618002 14F10227"
if !errorlevel!==0 goto Install-DN39B2

rem with UWP and without Senary APO
type [senary_temp].txt|findstr /i "80860103 1D051407 1D051406 1D051408 1D051404 1D051405 1D051403 1D051401 1D051400 1D051402 1D051382 10251750 10251751 1D05140B 14F10226 14F10379 1EE822C5 10251657 1D051301 1EC91A08 278212C3 1D05120A 1D05120b 1D05120c 1D05120d 104310A3 10431313 1D05124A 1D05124C 1D05124E 1D05124F 1D05126A"
if !errorlevel!==0 goto Install-MRID6-ASUS

rem withUWP, with headset mic Senary APO and Intel dmic Senary APO
type [senary_temp].txt|findstr /i "1E508033 1EC91A0A 1EC91A09 1EC91A07 1EC91A05 1EC91A06 1EC91A01 1EC91A04 1E39B991 1E39A991"
if !errorlevel!==0 goto Install-Haier

rem withUWP, with headset mic Senary APO and PortC Senary APO
type [senary_temp].txt|findstr /i "1D05137D 14F10343 278212B5 278212B6 14F103A3"
if !errorlevel!==0 goto Install-Zhaoxin


rem only install base and oem ext infs
echo pnputil /add-driver "cisstrtU-base.inf" /install
pnputil /add-driver "cisstrtU-base.inf" /install
echo pnputil /add-driver "cisstrtU-ext-OEM-common.inf" /install
pnputil /add-driver "cisstrtU-ext-OEM-common.inf" /install
goto end

:Install-ATN1
echo pnputil /add-driver "cisstrtU-base.inf" /install
pnputil /add-driver "cisstrtU-base.inf" /install
echo pnputil /add-driver "cisstrtU-ext-OEM-common.inf" /install
pnputil /add-driver "cisstrtU-ext-OEM-common.inf" /install
echo pnputil /add-driver SenaryAPO\SenaryAPO.inf /install
pnputil /add-driver ".\SenaryAPO\SenaryAPO.inf" /install
goto end

:Install-DN39B2
echo pnputil /add-driver "cisstrtU-base.inf" /install
pnputil /add-driver "cisstrtU-base.inf" /install
echo pnputil /add-driver "cisstrtU-ext-OEM-common.inf" /install
pnputil /add-driver "cisstrtU-ext-OEM-common.inf" /install
echo pnputil /add-driver SenaryAPO/"SenaryAPO.inf" /install
pnputil /add-driver SenaryAPO/"SenaryAPO.inf" /install
echo pnputil /add-driver SenaryAPO\IntcDMicExt_Senary.inf" /install
pnputil /add-driver ".\SenaryAPO\IntcDMicExt_Senary.inf" /install
goto end

:Install-Zhaoxin
echo pnputil /add-driver "cisstrtU-base.inf" /install
pnputil /add-driver "cisstrtU-base.inf" /install
echo pnputil /add-driver "cisstrtU-ext-OEM-common.inf" /install
pnputil /add-driver "cisstrtU-ext-OEM-common.inf" /install
echo pnputil /add-driver ".\SynaAPO\cisstrtU-component-OEM.inf" /install
pnputil /add-driver ".\SynaAPO\cisstrtU-component-OEM.inf" /install
echo pnputil /add-driver ".\SynaAPO\AudioService.inf" /install
pnputil /add-driver ".\SynaAPO\AudioService.inf" /install
echo pnputil /add-driver "SenaryCaptureEffects\SenaryCaptureEffects.inf" /install
pnputil /add-driver ".\SenaryCaptureEffects\SenaryCaptureEffects.inf" /install
goto end

:Install-MRID6-ASUS
echo pnputil /add-driver "cisstrtU-base.inf" /install
pnputil /add-driver "cisstrtU-base.inf" /install
echo pnputil /add-driver "cisstrtU-ext-OEM-common.inf" /install
pnputil /add-driver "cisstrtU-ext-OEM-common.inf" /install
echo pnputil /add-driver ".\SynaAPO\cisstrtU-component-OEM.inf" /install
pnputil /add-driver ".\SynaAPO\cisstrtU-component-OEM.inf" /install
echo pnputil /add-driver ".\SynaAPO\AudioService.inf" /install
pnputil /add-driver ".\SynaAPO\AudioService.inf" /install
goto end

:Install-Haier
echo pnputil /add-driver "cisstrtU-base.inf" /install
pnputil /add-driver "cisstrtU-base.inf" /install
echo pnputil /add-driver "cisstrtU-ext-OEM-common.inf" /install
pnputil /add-driver "cisstrtU-ext-OEM-common.inf" /install
echo pnputil /add-driver ".\SynaAPO\cisstrtU-component-OEM.inf" /install
pnputil /add-driver ".\SynaAPO\cisstrtU-component-OEM.inf" /install
echo pnputil /add-driver ".\SynaAPO\AudioService.inf" /install
pnputil /add-driver ".\SynaAPO\AudioService.inf" /install
echo pnputil /add-driver SenaryAPO/"SenaryAPO.inf" /install
pnputil /add-driver ".\SenaryAPO\SenaryAPO.inf" /install
echo pnputil /add-driver SenaryAPO/"IntcDMicExt_Senary.inf" /install
pnputil /add-driver ".\SenaryAPO\IntcDMicExt_Senary.inf" /install


:end
if exist [senary_temp].txt del [senary_temp].txt
REM restart two services
net.exe stop "audioendpointbuilder" /y
net.exe start "audioendpointbuilder"
net stop audiosrv /y
net start audiosrv

echo ===============================

