@echo off
rem created by Dragon 2025-08-22
rem uninstall all goodix touch pad drivers and install *.inf 
rem 脚本作用是卸载所有汇顶TP驱动并安装当前目录/子目录所有inf驱动
cd /d %~dp0
setlocal enabledelayedexpansion
echo Check if it is running with administrator privileges
net session >nul 2>&1
if %errorlevel% neq 0 (
    echo get administrator privileges ...
    goto UACPrompt
) else (
    echo aready have administrator privileges
    goto gotAdmin
)

:UACPrompt
    echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
    echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
    "%temp%\getadmin.vbs"
    del "%temp%\getadmin.vbs"
    exit /b

:gotAdmin
    echo using PowerShell extract the file name of OEM *. inf
	echo Uninstall all drivers containing Goodix
	powershell -Command "echo %CD%;for(4 -lt 5){$output = pnputil /enum-drivers |findstr '.'|findstr /n '.';$output>temp.txt; $g= ($output -match '.*goodix') ;echo 'g----'$g;if(-not $g){break}; echo $g.length;echo 'match--'($g[0] -match '[0-9]*');echo $Matches[0];$t= $output[$Matches[0]-2];echo $t;$t -match 'oem[0-9]*.inf';echo $Matches[0];pnputil /delete-driver $Matches[0] /force;if($g.length -lt 2){echo '...............';break}}"
    powershell -Command "pnputil /add-driver *.inf /subdirs /install"
	del temp.txt
endlocal

