@echo off
rem 32-bit version of MTK_USB_Serial_Port_Driver works ONLY on 32-bit Windows.
rem 64-bit version of MTK_USB_Serial_Port_Driver works ONLY on 64-bit Windows.
rem EXECEPTION: 32-bit version of MTK Drivers cannot run on Windows PE x64.
rem 64-bit version is faster and doesn't have the 2GB RAM per process limitation.

title=MTK Drivers Installer automatic check CPU type

IF %PROCESSOR_ARCHITECTURE% == x86 (IF NOT DEFINED PROCESSOR_ARCHITEW6432 goto bit32)
goto bit64
:bit32
echo 32-bit
set xOS="x86"
goto cont
:bit64
echo 64-bit
set xOS="x64"
:cont

for /f "tokens=*" %%a in ('dir /b /od "%~dp0MTK_USB_Serial_Port_Driver_%xOS%*.msi"') do set "SDIEXE=%%a"
if exist "%~dp0%SDIEXE%" (
 start "MTK Drivers installer" /d"%~dp0" "%~dp0%SDIEXE%" %1 %2 %3 %4 %5 %6 %7 %8 %9
 goto ex
) else (
 echo.
 echo  Not found 'MTK Drivers installer'!
 echo.
 timeout 6
)
:ex