I have this code that just tries to ping using shell with the following command line.
LOG lines
Issues to resolve:
- Is it possible that cmd needs special permissions?
-Special characters (accents and others) -> Pinger.Encoding = "Encoding Value"
B4X:
Sub Class_Globals
Private Pinger As Shell
Public Destination As String
Public Attempts As Byte
Public Timeout As Int
End Sub
Public Sub Initialize(CallBack As Object, EventName As String)
Destination = "google.com"
Attempts = 4
Timeout = 200
End Sub
Private Sub DesktopDoPing()
If Attempts = 0 Then
If xui.SubExists(mCallback, mEventName & "_PingError", 1) Then
CallSub2(mCallback, mEventName & "_PingError", "Attempts must be greater than or equal to 1")
End If
Else
If xui.SubExists(mCallback, mEventName & "_PingStarted", 0) Then
CallSub(mCallback, mEventName & "_PingStarted")
End If
'Pinger.Initialize("Desktop", "ping", Array(Destination, " -w " & Timeout, " -n " & Attempts))
Pinger.Initialize("Desktop", "cmd.exe", Array("/c ", " ping ", Destination, " -w " & Timeout, " -n " & Attempts))
If Pinger.IsInitialized Then
'The execution has a lifespan calculated as "response time * attempts" + 5 seconds.
Pinger.Run((Timeout * Attempts) + 5000)
End If
End If
End Sub
Private Sub Desktop_ProcessCompleted (Success As Boolean, ExitCode As Int, StdOut As String, StdErr As String)
Log(StdOut)
End Sub
LOG lines
WARNING: package com.sun.javafx.embed.swing.oldimpl not in javafx.swing
Waiting for debugger to connect...
Program started.
*** mainpage: B4XPage_Created
Ping started
*** mainpage: B4XPage_Appear
*** mainpage: B4XPage_Resize [mainpage]
~l041179649:
Haciendo ping a google.com [142.251.133.14] con 32 bytes de datos:
PING: error en la transmisi�n. Error general.
PING: error en la transmisi�n. Error general.
PING: error en la transmisi�n. Error general.
PING: error en la transmisi�n. Error general.
~l041179649:
Estad�sticas de ping para 142.251.133.14:
Paquetes: enviados = 4, recibidos = 0, perdidos = 4
(100% perdidos),
Issues to resolve:
- Is it possible that cmd needs special permissions?
-
Last edited: