@echo off
if exist "%SystemRoot%\SysWOW64" path %path%;%windir%\SysNative;%SystemRoot%\SysWOW64;%~dp0
bcdedit >nul
if '%errorlevel%' NEQ '0' (goto UACPrompt) else (goto UACAdmin)
:UACPrompt
%1 start "" mshta vbscript:createobject("shell.application").shellexecute("""%~0""","::",,"runas",1)(window.close)&exit
exit /B
:UACAdmin
cd /d "%~dp0"



.\LBGHWIDCHK.EXE "PCI\VEN_8086&DEV_51F0"
IF %ERRORLEVEL%==0 (SET HWVAR="PCI\VEN_8086&DEV_51F0") & GOTO :DEV1
.\LBGHWIDCHK.EXE "PCI\VEN_10EC&DEV_B852"
IF %ERRORLEVEL%==0 (SET HWVAR="PCI\VEN_10EC&DEV_B852") & GOTO :DEV2
.\LBGHWIDCHK.EXE "PCI\VEN_14C3&DEV_7961"
IF %ERRORLEVEL%==0 (SET HWVAR="PCI\VEN_14C3&DEV_7961") & GOTO :DEV3
GOTO :NONHWID

:DEV1
SET PACKAGENAME=Intel_WLAN
SET VERSION=22.100.0.3
SET INSTALLFOLDER=Intel_WLAN
SET BACKUPFOLDER=Intel_WLAN
SET SILIENTCMD=Install.cmd
SET PACKAGEID=Intel_WLAN
SET OS=WIN1064
SET MODTYPE=DRIVER
SET RecLog=.\MODULES.LOG
PUSHD "%~DP0%INSTALLFOLDER%\"
GOTO :INSTALL

:DEV2
SET PACKAGENAME=Realtek_WLAN
SET VERSION=6001.1.15.111
SET INSTALLFOLDER=Realtek_WLAN
SET BACKUPFOLDER=Realtek_WLAN
SET SILIENTCMD=Install.cmd
SET PACKAGEID=Realtek_WLAN
SET OS=WIN1064
SET MODTYPE=DRIVER
SET RecLog=.\MODULES.LOG
PUSHD "%~DP0%INSTALLFOLDER%\"
GOTO :INSTALL

:DEV3
SET PACKAGENAME=MTK_WLAN
SET VERSION=3.3.0.396
SET INSTALLFOLDER=MTK_WLAN
SET BACKUPFOLDER=MTK_WLAN
SET SILIENTCMD=Install.cmd
SET PACKAGEID=MTK_WLAN
SET OS=WIN1064
SET MODTYPE=DRIVER
SET RecLog=.\MODULES.LOG
PUSHD "%~DP0%INSTALLFOLDER%\"
GOTO :INSTALL

:INSTALL

ECHO %DATE% %TIME% START TO INSTALL (%PACKAGENAME%) >> %RecLog%
ECHO %DATE% %TIME% INSTALL FROM : "%~DP0%INSTALLFOLDER%\"   >> %RecLog%
ECHO %DATE% %TIME% SILIENT INSTALL CMD : %SILIENTCMD%   >> %RecLog%
CALL %SILIENTCMD%
IF %ERRORLEVEL% == 0 ( ECHO %MODTYPE%_%PACKAGEID%_[INFO]=%DATE% %TIME% DRIVER %PACKAGENAME% HAS BEEN INSTALL SUCCEFULLY!!! >> %RecLog%
) ELSE (
 ECHO %MODTYPE%_%PACKAGEID%_[INFO]=%DATE% %TIME% DRIVER %PACKAGENAME% INSTALL FAILED,BAD RETURN EXIT WITH %ERRORLEVEL% >> %RecLog%
)
GOTO END


:NONHWID
ECHO %MODTYPE%_%PACKAGEID%_[INFO]=%DATE% %TIME% NOT FOUND ANY MATCHED DEVICE ID,SOURCE HAVEN'T BEEN INSTALLED 
GOTO END

:END
ECHO %DATE% %TIME% FINISHED INSTALLING (%PACKAGEID%) (%PACKAGENAME%)
POPD