I'm at my wits end on this. So, I just want to build an app in VB.net that uses the adb (Android Debug Bridge) to get information about a device. Currently, I'm trying to get the device's brand using the command: adb shell getprop ro.product.brand which should return Amazon. However, when I try to use an if statement to see if the output of the adb command equals Amazon it always returns an error (stating it isn't an Amazon device). I've tried so much to get this worked and I cannot figure it out for the life of me. Does anyone have any suggestions on how this can be fixed? Am I missing something?
Public Class Form1
Function adb(ByVal Arguments As String) As String
Try
Dim My_Process As New Process()
Dim My_Process_Info As New ProcessStartInfo()
My_Process_Info.FileName = "cmd.exe"
My_Process_Info.Arguments = Arguments
My_Process_Info.WorkingDirectory = "adb\"
My_Process_Info.CreateNoWindow = True
My_Process_Info.UseShellExecute = False
My_Process_Info.RedirectStandardOutput = True
My_Process_Info.RedirectStandardError = True
My_Process.EnableRaisingEvents = True
My_Process.StartInfo = My_Process_Info
My_Process.Start()
Dim Process_ErrorOutput As String = My_Process.StandardOutput.ReadToEnd()
Dim Process_StandardOutput As String = My_Process.StandardOutput.ReadToEnd()
Console.WriteLine(Process_ErrorOutput)
Console.WriteLine(Process_StandardOutput)
' Return output by priority
If Process_ErrorOutput IsNot Nothing Then Return Process_ErrorOutput
If Process_StandardOutput IsNot Nothing Then Return Process_StandardOutput
Catch ex As Exception
Return ex.Message
End Try
Return "OK"
End Function
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Dim BrandofDev
BrandofDev = (adb("/c adb shell getprop ro.product.brand"))
If BrandofDev = "Amazon" Then
MsgBox("This is an amazon device.")
Else
MsgBox("This isn't an Amazon device.")
End If
End Sub
End Class