B4J Question File batch Windows (.bat)

Isac

Active Member
Licensed User
Longtime User
I can run a Windows batch file (.bat)?
it's possible ?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Yes.

B4X:
Sub AppStart (Args() As String)
   Dim shl As Shell
   shl.Initialize("shl", "cmd", Array("/c", "c:\temp\Test.bat"))
   shl.Run(-1)
   StartMessageLoop
   
End Sub

Sub shl_ProcessCompleted (Success As Boolean, ExitCode As Int, StdOut As String, StdErr As String)
   Log($"Success: ${Success},
Out: ${StdOut}
Error: ${StdErr}"$)
End Sub

Tip:
Start your batch file with the following command if you want it to always run it the batch file location (you can also set shl.WorkingDirectory):
B4X:
cd /d %~dp0
 
Upvote 0

Similar Threads

Top