I performed the test again and launched the application placed in the D:\TMP directory from where its .exe file was launched
I received:
Therefore, the 'File.GetFileParent' function returns the path of the parent (i.e. always root) file or folder, as instructed.
So, in my humble opinion, the function: 'File.GetFileParent(File.DirApp)' should not work, contrary to nature,
so why does it work for you? I have no idea.
In my case, this code snippet doesn't work for me while byz's code works for me.
I think this is because the shell which will be executed from the "running process" exe is inside \bin directory must call the "start-up" exe which is located 1 level up from the \bin directory as you can see in run_debug.bat
I am not sure how you produce the exe. Are you using Launch4j to create a single exe?
I create my exe using "Build Standalone Package" from B4J IDE menu where I get:
1 App.exe file in my ProjectName\B4J\Objects\temp\build ~17KB
1 App.exe file in my ProjectName\B4J\Objects\temp\build\bin ~46KB
When I run the 17KB App.exe, I think it is actually calling the 46KB App.exe inside \bin folder
and the 46KB App.exe is actually a copy of java.exe (~46KB) that being renamed.
What is showing on the Windows taskbar during runtime is the 46KB App.exe.
The 17KB App.exe behaves like a bootstrap or just a shortcut which will execute the following commands:
\bin\App.exe @release_java_modules.txt -m b4j/your.package.name.main
So I need to either restart the
App.exe (17KB) inside \build folder
or
App.exe (46KB) inside the \build\bin folder with extra parameters.
Either one of the following works for me:
B4X:
shl.Initialize("shl", "cmd.exe", Array As String("/c", "App.exe"))
shl.WorkingDirectory = File.GetFileParent(File.DirApp)
B4X:
shl.Initialize("shl", "App.exe", Array As String("@release_java_modules.txt", "-m", "b4j/your.package.name.main"))
shl.WorkingDirectory = File.DirApp