-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathXiaomi_find_devices.py
More file actions
147 lines (125 loc) · 4.84 KB
/
Xiaomi_find_devices.py
File metadata and controls
147 lines (125 loc) · 4.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/usr/bin/env python3
"""
Поиск устройств с проблемами в Windows Device Manager
"""
import subprocess
import re
import sys
def get_device_manager_devices():
"""Получает список всех устройств из Device Manager"""
try:
# Используем PowerShell для получения информации о устройствах
cmd = [
"powershell",
"-Command",
"Get-PnpDevice | Select-Object Status, Class, FriendlyName, InstanceId | Format-Table -AutoSize",
]
result = subprocess.run(
cmd, capture_output=True, text=True, encoding="cp1251", errors="ignore"
)
return result.stdout if result.stdout else ""
except Exception as e:
print(f"Ошибка получения списка устройств: {e}")
return ""
def get_problem_devices():
"""Получает устройства с проблемами через WMI"""
try:
cmd = [
"powershell",
"-Command",
"""
Get-WmiObject -Class Win32_PnPEntity | Where-Object {
$_.Status -ne "OK" -and $_.Status -ne $null
} | Select-Object Name, Status, DeviceID, ClassGuid | Format-Table -AutoSize
""",
]
result = subprocess.run(
cmd, capture_output=True, text=True, encoding="cp1251", errors="ignore"
)
return result.stdout if result.stdout else ""
except Exception as e:
print(f"Ошибка получения проблемных устройств: {e}")
return ""
def get_usb_devices():
"""Получает USB устройства"""
try:
cmd = [
"powershell",
"-Command",
"""
Get-WmiObject -Class Win32_USBHub | Select-Object Name, DeviceID, Status | Format-Table -AutoSize
""",
]
result = subprocess.run(
cmd, capture_output=True, text=True, encoding="cp1251", errors="ignore"
)
return result.stdout if result.stdout else ""
except Exception as e:
print(f"Ошибка получения USB устройств: {e}")
return ""
def get_android_devices():
"""Ищет Android устройства"""
try:
cmd = [
"powershell",
"-Command",
"""
Get-WmiObject -Class Win32_PnPEntity | Where-Object {
$_.Name -match "Android" -or
$_.Name -match "ADB" -or
$_.Name -match "Xiaomi" -or
$_.Name -match "Mi " -or
$_.Name -match "USB.*Android" -or
$_.DeviceID -match "VID_18D1" -or
$_.DeviceID -match "VID_2717"
} | Select-Object Name, Status, DeviceID, ClassGuid | Format-Table -AutoSize
""",
]
result = subprocess.run(
cmd, capture_output=True, text=True, encoding="cp1251", errors="ignore"
)
return result.stdout if result.stdout else ""
except Exception as e:
print(f"Ошибка поиска Android устройств: {e}")
return ""
def main():
print("=" * 60)
print("ПОИСК ПРОБЛЕМНЫХ УСТРОЙСТВ В DEVICE MANAGER")
print("=" * 60)
print("\n1. Все устройства с проблемами:")
print("-" * 40)
problem_devices = get_problem_devices()
if problem_devices and problem_devices.strip():
print(problem_devices)
else:
print("Проблемных устройств не найдено")
print("\n2. Android/Xiaomi устройства:")
print("-" * 40)
android_devices = get_android_devices()
if android_devices and android_devices.strip():
print(android_devices)
else:
print("Android/Xiaomi устройства не найдены")
print("\n3. USB устройства:")
print("-" * 40)
usb_devices = get_usb_devices()
if usb_devices and usb_devices.strip():
print(usb_devices)
else:
print("USB устройства не найдены")
print("\n4. Полный список устройств:")
print("-" * 40)
all_devices = get_device_manager_devices()
if all_devices and all_devices.strip():
print(all_devices)
else:
print("Не удалось получить список устройств")
print("\n" + "=" * 60)
print("РЕКОМЕНДАЦИИ:")
print("=" * 60)
print("1. Подключите ваше Xiaomi устройство")
print("2. Включите отладку по USB на устройстве")
print("3. Запустите скрипт снова")
print("4. Ищите устройства со статусом 'Error' или 'Unknown'")
if __name__ == "__main__":
main()