# Restore ADB driver for VID_0E8D - must run as admin $isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) if (-not $isAdmin) { Start-Process PowerShell -Verb RunAs -ArgumentList "-ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Wait exit } Write-Host "=== Restore ADB Driver ===" -ForegroundColor Cyan # Step 1: Remove the current Zadig WinUSB driver for VID_0E8D:PID_201C device Write-Host "Removing broken device node..." -ForegroundColor Yellow $devs = Get-PnpDevice | Where-Object { $_.InstanceId -like '*VID_0E8D*PID_201C*' } foreach ($dev in $devs) { Write-Host " Removing: $($dev.FriendlyName) [$($dev.InstanceId)] (Status: $($dev.Status))" pnputil /remove-device "$($dev.InstanceId)" 2>&1 } # Also remove PID_201D devices that might be cached wrong $devs2 = Get-PnpDevice | Where-Object { $_.InstanceId -like '*VID_0E8D*PID_201D*' } foreach ($dev in $devs2) { Write-Host " Removing: $($dev.FriendlyName) [$($dev.InstanceId)]" pnputil /remove-device "$($dev.InstanceId)" 2>&1 } # Step 2: Remove all Zadig (libwdi) OEM drivers for MediaTek Write-Host "" Write-Host "Removing Zadig OEM drivers..." -ForegroundColor Yellow $output = pnputil /enum-drivers 2>&1 | Out-String $blocks = $output -split "(?=Published Name:)" foreach ($block in $blocks) { if ($block -match "libwdi" -and ($block -match "0E8D" -or $block -match "android\.inf" -or $block -match "mt65xx")) { if ($block -match "Published Name:\s+(oem\d+\.inf)") { $drvName = $Matches[1] Write-Host " Deleting: $drvName" pnputil /delete-driver $drvName /force 2>&1 } } } # Step 3: Make sure the Google/proper ADB driver is available Write-Host "" Write-Host "Ensuring ADB driver is available..." -ForegroundColor Yellow $googleInf = "$env:LOCALAPPDATA\Android\Sdk\extras\google\usb_driver\android_winusb.inf" if (Test-Path $googleInf) { Write-Host " Re-adding Google USB driver..." pnputil /add-driver $googleInf /install 2>&1 } # Step 4: Rescan hardware Write-Host "" Write-Host "Scanning for hardware changes..." -ForegroundColor Yellow pnputil /scan-devices 2>&1 Write-Host "" Write-Host "DONE. Now UNPLUG and REPLUG the USB cable." -ForegroundColor Green Write-Host "Windows should re-detect the device with the correct ADB driver." -ForegroundColor Green Write-Host "" Start-Sleep -Seconds 3 # Check what we have now Write-Host "Current USB devices:" -ForegroundColor Yellow Get-PnpDevice -Status "OK" | Where-Object { $_.InstanceId -like '*0E8D*' -or $_.InstanceId -like '*18D1*' } | Select-Object Status, Class, InstanceId, FriendlyName | Format-Table -AutoSize Read-Host "Press Enter to close"