Using --StartPath
works for me in combination with jvm
instead of exe
as --StartMode
and using Apache Commons Daemon 1.1 downloaded just some hours ago.
Without --StartPath
, my daemon couldn't find it's config file even if prunsrv
was started on the shell using pushd
with the correct dir. Process Monitor showed that the dir where prunsrv
was stored in was used as current working dir instead. With --StartPath
, and only that addition to what I had before, my daemon finds it's own config file now AND Logback is properly initializing as well, using relative paths in its logback.xml
only making sense in case of the proper current working dir.
So whatever you did in the past, it might have been wrong or that feature might have been added since then. Looking at the source code, I don't have the feeling that --StartPath
depends or influences Exes only as well:
if (_jni_startup) {
if (IS_EMPTY_STRING(SO_STARTPATH))
SO_STARTPATH = gStartPath;
if (IS_VALID_STRING(SO_STARTPATH)) {
/* If the Working path is specified change the current directory */
SetCurrentDirectoryW(SO_STARTPATH);
}
https://github.com/apache/commons-daemon/blob/trunk/src/native/windows/apps/prunsrv/prunsrv.c#L1201
Let's hope this is not undefined behaviour, because the docs in deed read different:
Working path for the start image executable.
OTOH, it is the way it is for a very long time already:
https://github.com/apache/commons-daemon/commit/4664a01b6dfc8f5e34596f6b327d4498783c2a18#diff-880a104d7fb49226503af45f7d72593eR850