@echo off

set uaccheck=0

:CheckUAC
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
if '%errorlevel%' NEQ '0' ( goto UACAccess ) else ( goto DEPLOY )

:UACAccess
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\uac_get_admin.vbs"
set params = %*:"=""
echo UAC.ShellExecute "cmd.exe", "/c %~s0 %params%", "", "runas", 1 >> "%temp%\uac_get_admin.vbs"
"%temp%\uac_get_admin.vbs"
del "%temp%\uac_get_admin.vbs"
exit /b


:DEPLOY
chcp 949
color 9F
pushd %~dp0
cls

echo Start Installing...
@set L=C:\windows\temp\Driver_install.log
@set L2=C:\Windows\temp\Driver_install_amd_audio.log
@set IP=[********Install Pass********]
@set IPR=[********Install Pass, Restart is need********]
@set IF=[********Install Fail********]

@echo. > %L2%
@echo [%time%]=========Install Intel ACP driver========= >> %L%
@echo [%time%]=========Install Intel ACP driver========= >> %L2%

:ins1
pnputil /add-driver "%~dp0Drivers\amdacpafd.inf" /install >> %L%
@if %errorlevel%==0 (echo [%time%]%IP% >> %L% & echo [%time%]%IP% >> %L2% & goto ins2)
@if %errorlevel%==259 (echo [%time%]%errorlevel% >> %L% & goto ins2)
@if %errorlevel%==3010 (echo [%time%]%IPR% >> %L% & echo [%time%]%IPR% >> %L2% & goto ins2)
@if not %errorlevel%==0 goto ERR

:ins2
pnputil /add-driver "%~dp0Drivers\amdacpbus.inf" /install >> %L%
@if %errorlevel%==0 (echo [%time%]%IP% >> %L% & echo [%time%]%IP% >> %L2% & goto resultpass)
@if %errorlevel%==259 (echo [%time%]%errorlevel% >> %L% & goto resultpass)
@if %errorlevel%==3010 (echo [%time%]%IPR% >> %L% & echo [%time%]%IPR% >> %L2% & goto resultpass)
@if not %errorlevel%==0 goto ERR

:resultpass
@echo [%time%]=========Intel ACP wifi driver Install Complete========= >> %L%
@echo [%time%]=========Intel ACP wifi driver Install Complete========= >> %L2%
@echo. >> %L2%
ECHO ERRRORLEVEL=%ERRORLEVEL% >> %L%
@set LL=C:\Windows\temp\ACP.log
@echo [%time%] >>%LL%
type %L2%
pause
EXIT /B 0

:ERR
echo [%time%]%IF% >> %L%
echo [%time%]%IF% >> %L2%
ECHO ERRRORLEVEL=%ERRORLEVEL% >> %L%
ECHO ERRRORLEVEL=%ERRORLEVEL% >> %L2%
@echo. >> %L2%
type %L2%
pause
EXIT /B 1