@echo off
%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit
cls
echo Checking Minisforum Log folder path...
if not exist C:\Minisforum.sav\DrverInstall md C:\Minisforum.sav\DrverInstall & attrib +H C:\Minisforum.sav

echo Start Installing Realtek Audio driver...
@set L=C:\Minisforum.sav\DrverInstall\RealtekAudio.log
@set IP=[===========Install Pass===========]
@set IPR=[===========Install Pass, Restart is need===========]
@set IF=[===========Install Fail===========]

@echo [%time%]=========Install Realtek Audio driver========= >> %L%

:ins1
pnputil -a "%~dp0Realtek\ExtRtk_9629.1\HDX_WhiteExt_RTK.inf" >> %L%
@if %errorlevel%==0 (echo [%time%]%IP% >> %L% & goto ins2)
@if %errorlevel%==259 (echo [%time%]%errorlevel% >> %L% & goto ins2)
@if %errorlevel%==3010 (echo [%time%]%IPR% >> %L% & goto ins2)
@if not %errorlevel%==0 goto ERR

:ins2
pnputil -a "%~dp0Realtek\Codec_9629.1\HDXACPWhite.inf" /install >> %L%
@if %errorlevel%==0 (echo [%time%]%IP% >> %L% & goto ins3)
@if %errorlevel%==259 (echo [%time%]%errorlevel% >> %L% & goto ins3)
@if %errorlevel%==3010 (echo [%time%]%IPR% >> %L% & goto ins3)
@if not %errorlevel%==0 goto ERR

:ins3
pnputil -a "%~dp0Realtek\RealtekAPO_12_1139\RealtekAPO.inf" /install >> %L%
@if %errorlevel%==0 (echo [%time%]%IP% >> %L% & goto ins4)
@if %errorlevel%==259 (echo [%time%]%errorlevel% >> %L% & goto ins4)
@if %errorlevel%==3010 (echo [%time%]%IPR% >> %L% & goto ins4)
@if not %errorlevel%==0 goto ERR

:ins4
pnputil -a "%~dp0Realtek\RealtekAPO_13_1139\RealtekAPO.inf" /install >> %L%
@if %errorlevel%==0 (echo [%time%]%IP% >> %L% & goto ins5)
@if %errorlevel%==259 (echo [%time%]%errorlevel% >> %L% & goto ins5)
@if %errorlevel%==3010 (echo [%time%]%IPR% >> %L% & goto ins5)
@if not %errorlevel%==0 goto ERR

:ins5
pnputil -a "%~dp0Realtek\RealtekASIO_10\RealtekASIO.inf" /install >> %L%
@if %errorlevel%==0 (echo [%time%]%IP% >> %L% & goto ins6)
@if %errorlevel%==259 (echo [%time%]%errorlevel% >> %L% & goto ins6)
@if %errorlevel%==3010 (echo [%time%]%IPR% >> %L% & goto ins6)
@if not %errorlevel%==0 goto ERR

:ins6
pnputil -a "%~dp0Realtek\RealtekHSA_319\RealtekHSA.inf" /install >> %L%
@if %errorlevel%==0 (echo [%time%]%IP% >> %L% & goto ins7)
@if %errorlevel%==259 (echo [%time%]%errorlevel% >> %L% & goto ins7)
@if %errorlevel%==3010 (echo [%time%]%IPR% >> %L% & goto ins7)
@if not %errorlevel%==0 goto ERR

:ins7
pnputil -a "%~dp0Realtek\RealtekService_698\RealtekService.inf" /install >> %L%
@if %errorlevel%==0 (echo [%time%]%IP% >> %L% & goto resultpass)
@if %errorlevel%==259 (echo [%time%]%errorlevel% >> %L% & goto resultpass)
@if %errorlevel%==3010 (echo [%time%]%IPR% >> %L% & goto resultpass)
@if not %errorlevel%==0 goto ERR

:resultpass
@echo [%time%]=========Intel Realtek Audio Install complete========= >> %L%
ECHO ERRRORLEVEL=%ERRORLEVEL% >> %L%
EXIT /B 0

:ERR
echo [%time%]%IF% >> %L%
ECHO ERRRORLEVEL=%ERRORLEVEL% >> %L%
EXIT /B 1