B4J Question ipconfig with jshell

Isac

Active Member
Licensed User
Longtime User
I can not recall the cmd, what does not work?

you can recover ipconfig on a message box?

B4X:
Dim J As Shell
J.Initialize("J","cmd.exe",Null)
   J.WorkingDirectory="C:\Windows\System32\cmd"
   J.Run(5000) 
   StartMessageLoop

thank you
 

Isac

Active Member
Licensed User
Longtime User
does not work, out this error:

Waiting for debugger to connect...
Program started.
An error occurred:
(Line: 0) null
java.lang.Exception: Sub appstart signature does not match expected signature.
public static anywheresoftware.b4a.pc.RemoteObject b4j.example.main_subs_0._appstart(anywheresoftware.b4a.pc.RemoteObject) throws java.lang.Exception
 
Upvote 0

Isac

Active Member
Licensed User
Longtime User
I'm sorry but it works, I used: NON - IU (console)

but how can I pull on a message box or else the output of ipconfig?
it's possible to do it?

B4X:
ub shl_ProcessCompleted (Success As Boolean, ExitCode As Int, StdOut As String, StdErr As String)
   Dim em As Msgboxes
   If Success Then
        em.Show(StdOut,"IPCONFIG")
     Log(StdOut)
   End If
End Sub

thanks Erel
 
Last edited:
Upvote 0

Isac

Active Member
Licensed User
Longtime User
B4J version: 4.70
Parsing code. (0.00s)
Compiling code. Error
Error compiling program.
Error description: Unknown member: tostring
Occurred on line: 24
fx.Msgbox(MainForm, StdOut.ToString, "IPCONFIG")
Word: tostring




B4X:
'Non-UI application (console / server application)
#Region Project Attributes
    #CommandLineArgs:
    #MergeLibraries: True
#End Region

Sub Process_Globals
    Dim fx As JFX
    Dim MainForm As Form
   
End Sub

Sub AppStart (Args() As String)
  Dim s As Shell
   s.Initialize("shl", "\windows\System32\ipconfig", Null)
   s.Run(-1)
   StartMessageLoop
      
End Sub

Sub shl_ProcessCompleted (Success As Boolean, ExitCode As Int, StdOut As String, StdErr As String)
   If Success Then
     Log(StdOut)
     fx.Msgbox(MainForm, StdOut.ToString, "IPCONFIG")
   End If
End Sub

--------------------------------------------------------------------
I also tried without ToString but always generates error:


java.lang.ExceptionInInitializerError
at javafx.scene.control.DialogPane.createContentLabel(DialogPane.java:167)
at javafx.scene.control.DialogPane.<init>(DialogPane.java:218)
at javafx.scene.control.Dialog.<init>(Dialog.java:506)
at javafx.scene.control.Alert.<init>(Alert.java:245)
at javafx.scene.control.Alert.<init>(Alert.java:223)
at anywheresoftware.b4j.objects.JFX.Msgbox2(JFX.java:167)
at anywheresoftware.b4j.objects.JFX.Msgbox(JFX.java:148)
at b4j.example.main._shl_processcompleted(main.java:90)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:612)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:229)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:90)
at anywheresoftware.b4a.BA$4.run(BA.java:196)
at anywheresoftware.b4a.keywords.SimpleMessageLoop.runMessageLoop(SimpleMessageLoop.java:30)
at anywheresoftware.b4a.StandardBA.startMessageLoop(StandardBA.java:26)
at anywheresoftware.b4a.ShellBA.startMessageLoop(ShellBA.java:111)
at anywheresoftware.b4a.keywords.Common.StartMessageLoop(Common.java:131)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:301)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:90)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
at b4j.example.main.main(main.java:29)
Caused by: java.lang.IllegalStateException: Toolkit not initialized
at com.sun.javafx.application.PlatformImpl.runLater(PlatformImpl.java:273)
at com.sun.javafx.application.PlatformImpl.runLater(PlatformImpl.java:268)
at com.sun.javafx.application.PlatformImpl.setPlatformUserAgentStylesheet(PlatformImpl.java:550)
at com.sun.javafx.application.PlatformImpl.setDefaultPlatformUserAgentStylesheet(PlatformImpl.java:512)
at javafx.scene.control.Control.<clinit>(Control.java:87)
... 36 more
Error occurred on line: 24 (Main)
java.lang.RuntimeException: java.lang.ExceptionInInitializerError
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:114)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:90)
at anywheresoftware.b4a.BA$4.run(BA.java:196)
at anywheresoftware.b4a.keywords.SimpleMessageLoop.runMessageLoop(SimpleMessageLoop.java:30)
at anywheresoftware.b4a.StandardBA.startMessageLoop(StandardBA.java:26)
at anywheresoftware.b4a.ShellBA.startMessageLoop(ShellBA.java:111)
at anywheresoftware.b4a.keywords.Common.StartMessageLoop(Common.java:131)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:301)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:90)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
at b4j.example.main.main(main.java:29)
Caused by: java.lang.ExceptionInInitializerError
at javafx.scene.control.DialogPane.createContentLabel(DialogPane.java:167)
at javafx.scene.control.DialogPane.<init>(DialogPane.java:218)
at javafx.scene.control.Dialog.<init>(Dialog.java:506)
at javafx.scene.control.Alert.<init>(Alert.java:245)
at javafx.scene.control.Alert.<init>(Alert.java:223)
at anywheresoftware.b4j.objects.JFX.Msgbox2(JFX.java:167)
at anywheresoftware.b4j.objects.JFX.Msgbox(JFX.java:148)
at b4j.example.main._shl_processcompleted(main.java:90)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:612)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:229)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
... 16 more
Caused by: java.lang.IllegalStateException: Toolkit not initialized
at com.sun.javafx.application.PlatformImpl.runLater(PlatformImpl.java:273)
at com.sun.javafx.application.PlatformImpl.runLater(PlatformImpl.java:268)
at com.sun.javafx.application.PlatformImpl.setPlatformUserAgentStylesheet(PlatformImpl.java:550)
at com.sun.javafx.application.PlatformImpl.setDefaultPlatformUserAgentStylesheet(PlatformImpl.java:512)
at javafx.scene.control.Control.<clinit>(Control.java:87)
... 36 more
java.lang.RuntimeException: java.util.NoSuchElementException
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:114)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:90)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
at b4j.example.main.main(main.java:29)
Caused by: java.util.NoSuchElementException
at java.util.LinkedList.removeFirst(LinkedList.java:270)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:320)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
... 3 more
Program terminated (StartMessageLoop was not called).
 
Upvote 0

jmon

Well-Known Member
Licensed User
Longtime User
Just write "StdOut", instead of "StdOut.ToString"
[edit] sorry I see you tried already.

This maybe cause because you run a non-ui, and it cannot show the msgbox. Try with a UI b4j program.
 
Upvote 0

Isac

Active Member
Licensed User
Longtime User
ok solved

StartMessageLoop only works for 'Non-UI application




so I commented


B4X:
   s.Initialize("shl", "\windows\System32\ipconfig", Null)
   s.Run(-1)
'   StartMessageLoop


Now comes a second problem:
when I enter ipconfig / all or netstat-a.........
does not work

maybe I have to add it in a different way?

B4X:
   s.Initialize("shl", "\windows\System32\ipconfig/all", Null)
   s.Run(-1)
'   StartMessageLoop
 

Attachments

  • ip.PNG
    ip.PNG
    14.4 KB · Views: 372
Upvote 0

Isac

Active Member
Licensed User
Longtime User
ok solved

B4X:
 s.Initialize("shl", "\windows\System32\ipconfig", _
Array As String("/all"))
   s.Run(-1)
 
Upvote 0
Top