Private Sub SearchAllDevice()
Dim Device As String
Dim batFile As String
batFile = "@ECHO OFF" & vbCrLf
batFile = batFile & txtAdbPath.Text.Substring(0, txtAdbPath.Text.IndexOf(":") + 1) & vbCrLf
batFile = batFile & "cd " & txtAdbPath.Text.Substring(0, txtAdbPath.Text.LastIndexOf("\")) & vbCrLf
batFile = batFile & "adb.exe devices > " & Chr(34) & StartupPath & "\device.tmp" & Chr(34) & vbCrLf
File.WriteAllText(StartupPath & "\batFile.bat", batFile)
Dim AdbProcess As ProcessStartInfo
AdbProcess = New ProcessStartInfo(StartupPath & "\batFile.bat")
Dim pp As Process = Process.Start(AdbProcess)
pp.WaitForExit()
If File.Exists(StartupPath & "\device.tmp") Then
Dim strTemp() As String = File.ReadAllText(StartupPath & "\device.tmp").Split(vbCrLf)
File.Delete(StartupPath & "\device.tmp")
File.Delete(StartupPath & "\batFile.bat")
CheckedListBox1.Items.Clear()
For i As Integer = 0 To strTemp.Length - 1
Device = strTemp(i).Trim
If Device.EndsWith("device") Then
Device = Device.Substring(0, Device.IndexOf(vbTab))
CheckedListBox1.Items.Add(Device)
End If
Next
End If
End Sub