Luiz
Luiz

Reputation: 2539

Windows Task Scheduler Program Ends Immediately

I have a Java executable (.exe) with a given JRE build in the same folder, which it uses to actually run.

I want to put this executable on Windows Task Scheduler.

I did some tests with some C++ hello world programs, and all went fine. This Java program, running directly (by two clicks or whatever) works all fine too (it is supposed to write to a file and end).

However, when I put the Java program in the Task Scheduler, it exits immediately, with status code 0x0 (success) and nothing is actually performed.

At Windows Task Manager, I see that javaw.exe starts and exits in a glimpse.

What could it be? Something related to Java? Something due to a specific task scheduler flag?

Aditional:

Upvotes: 0

Views: 3445

Answers (2)

ssc327
ssc327

Reputation: 710

When you run an application with Windows Scheduler, if that application has dependencies to other files via relative path, then you need to set the start in setting for the task. This sets the path from where execution will begin.

Alternatively you can use a command file and have it navigate to the correct directory first.

Upvotes: 4

Luiz
Luiz

Reputation: 2539

Just figured out that the problem was that the program was actually being executed in the wrong folder, in order that the output file wasn't where I thought it would.

The output file was being write in the starting folder, not the program's folder.

Upvotes: 0

Related Questions