yo3ggx Active Member Licensed User Longtime User Jun 29, 2023 #1 Hello. I try to run an exe file using jShell. The following simple code is used: B4X: Dim sh1 as Shell sh1.Initialize("sh1","myapp.exe",Array As String("-d","1","-p","5174")) sh1.WorkingDirectory = "C:\MyApp" sh1.RunWithOutputEvents(-1) then I have B4X: Sub sh1_ProcessCompleted(Success As Boolean, ExitCode As Int, StdOut As String, StdErr As String) Log(StdOut) Log("Error: " & StdErr) End Sub When executed, I get the following error: B4X: Error: org.apache.commons.exec.ExecuteException: Execution failed (Exit value: -559038737. Caused by java.io.IOException: Cannot run program "myapp.exe" (in directory "C:\MyApp"): CreateProcess error=2, The system cannot find the file specified) If from Windows command prompt I enter the command: B4X: C:\MyApp\myapp.exe -d 1 -p 5174 the application is executed. What I'm doing wrong? Thank you.
Hello. I try to run an exe file using jShell. The following simple code is used: B4X: Dim sh1 as Shell sh1.Initialize("sh1","myapp.exe",Array As String("-d","1","-p","5174")) sh1.WorkingDirectory = "C:\MyApp" sh1.RunWithOutputEvents(-1) then I have B4X: Sub sh1_ProcessCompleted(Success As Boolean, ExitCode As Int, StdOut As String, StdErr As String) Log(StdOut) Log("Error: " & StdErr) End Sub When executed, I get the following error: B4X: Error: org.apache.commons.exec.ExecuteException: Execution failed (Exit value: -559038737. Caused by java.io.IOException: Cannot run program "myapp.exe" (in directory "C:\MyApp"): CreateProcess error=2, The system cannot find the file specified) If from Windows command prompt I enter the command: B4X: C:\MyApp\myapp.exe -d 1 -p 5174 the application is executed. What I'm doing wrong? Thank you.
Erel B4X founder Staff member Licensed User Longtime User Jun 29, 2023 #2 You need to pass the full path in the Initialize line. It is relative to the app folder, not the "WorkingDirectory". Upvote 0
You need to pass the full path in the Initialize line. It is relative to the app folder, not the "WorkingDirectory".
yo3ggx Active Member Licensed User Longtime User Jun 29, 2023 #3 Erel said: You need to pass the full path in the Initialize line. It is relative to the app folder, not the "WorkingDirectory". Click to expand... This was my mistake. I try with the full path (like for WorkingDirectory), not relative path. Thank you. Last edited: Jun 29, 2023 Upvote 0
Erel said: You need to pass the full path in the Initialize line. It is relative to the app folder, not the "WorkingDirectory". Click to expand... This was my mistake. I try with the full path (like for WorkingDirectory), not relative path. Thank you.