B4J Question Relative path in #CustomBuildAction

jmon

Well-Known Member
Licensed User
Longtime User
Hello,

As the title says, I'm trying to add a relative path to the custombuild action, but this doesn't work:
B4X:
#CustomBuildAction: 2, .\myScript.bat,

"myScript.bat" is in /Objects/myScript.bat.

Is it possible?

Thank you
 

tchart

Well-Known Member
Licensed User
Longtime User
@jmon the expected path of the batch file is actually the B4J programs file folder.

For example mine is C:\Apps\B4J

So if I want to run myScript.bat (without pathing it) it would need to be in C:\Apps\B4J

I used Process Monitor to see what file B4J was trying to execute. What I have noticed is that if no path is specified then the space between the comma and the script name is included.

ie B4J was trying to call C:\Apps\B4J\ myScript.bat (there is a space between the last slash and the script name.

To solve this use remove the space;

B4X:
#CustomBuildAction: 2,myScript.bat,

In your case .\myScript.bat then B4J will be looking in C:\Apps\B4J but you dont need the .\
 
Upvote 0

jmon

Well-Known Member
Licensed User
Longtime User
Upvote 0

jmon

Well-Known Member
Licensed User
Longtime User
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
The example code I posted in 1st post says it can't find the file.
(It is always better to post the error message when posting questions)

You are correct. You can use this code to run a batch file from the Objects folder:
B4X:
#CustomBuildAction: 2,\windows\system32\cmd.exe, /c myscript.bat
 
Upvote 0

jmon

Well-Known Member
Licensed User
Longtime User
(It is always better to post the error message when posting questions)
Yes, sorry I couldn't access my computer when I replied. This is the error message for future reference:
B4X:
B4J version: 4.70
Parsing code.    (0.00s)
Compiling code.    (0.32s)
Compiling layouts code.    (0.01s)
Organizing libraries.    (0.00s)
Compiling generated Java code.    (0.91s)
Building jar file.    (0.42s)
    Jar file created: M:\B4j\Tests\TestBuild\Objects\TestBuild.jar
Running custom action.    Error
Cannot find:  .\test.bat
Please configure paths (Tools - Configure Paths).
You can use this code to run a batch file from the Objects folder
Great, thanks a lot, it works!
 
Upvote 0
Top