Hello,
I am trying to run a java program through the task scheduler on an old windows server 2012R2.
My script runs when I double click on it, or if I run directly from the CMD screen.
This is a batch program that doesn't need any interaction with the user, nor does it display anything on the screen. Really a pure batch, command line script.
When running it through the task scheduler, it says that everything runs fine. I've checked the Event Log, and I can see that it was started, and also that it finished successfully. Everything is finished in less than one second.
My script needs to run for at least 20 days... so be finished in less that 1 second, this is not normal.
I've added some output redirection, added an "ECHO Start" and "ECHO End", and in the output file, I can see the Start and the End, but nothing on the Java part.
Like it was "discarded" somehow.
In the Task Scheduler, it works if I select "Run only when user is logged on"
But it doesn't work for "Run whether user is logged on or not". It doesn't matter if the "Do not store password" is selected or not, or if the "Run with highest privileges" is selected or not... I've tried them all... :-(
Obviously for my case, I need that it is started even if I am not logged on...
Here is my batch file:
echo START > D:\my_log.txt 2>&1
set CLASSPATH=XXXXX
"C:\Program Files\AdoptOpenJDK\jre-8.0.265.01-hotspot\bin\java.exe" -cp %CLASSPATH% com.exporting.ExportAll %* >> D:\my_log.txt 2>&1
echo END >> D:\my_log.txt 2>&1
I've tried with another small Java program, and it works with the task scheduler and without.
Now I am a bit in a very strange situation, where I have no clue on why it does work for some Java programs, and for others it doesn't work at all...
Does anybody has any idea how I can debug that?
Thank you very much in helping for this very frustrating situation....
Cheers,
Alessandro