0

I have created a Java Program and also created an Executable jar file and store it in the same folder. In this folder, I have other documents such as log4j.properties and a some a log file housekeep.log. My main.java is stored under the src folder. I also created a bat file, which is running fine when I fire it manually. However, when I am trying to run it on a task scheduler, I cannot read the housekeep.log and also the log4j.properties and it gave me an Access is deined error. java.io.FileNotFoundExecption:housekeep.log <Access is Deined> . How can I fix this issue?

Here is my code for my bat file.

@echo off
java -Xms512M -Xmx512M -jar C:\Users\admin\workspace\housekeep\housekeep.jar -o true
PAUSE
RedRocket
  • 1,643
  • 7
  • 28
  • 51
  • sounds like a problem concerning users and the corresponding rights. What os are you using? In case of windows try to start the task as the same user as in the interactive session. – chris Aug 06 '15 at 05:02
  • I am using windows, the one that work is I tried to use this http://stackoverflow.com/questions/4437701/run-a-batch-file-with-windows-task-scheduler as an example by adding an argument, but I thought there are code that can actually do that. – RedRocket Aug 06 '15 at 05:39
  • Task scheduler runs your `bat` script under another working directory, I guess `%windir%\system32`. Switch to right one using `pushd "%~dp0"` command (or `cd /D %~dp0`) – JosefZ Aug 06 '15 at 05:50

0 Answers0