Schedule a Java ANT program on windows
- Make sure you can navigate to the path where you have the build.xml stored and run the ant command from command prompt
- Once confirmed that you are able to run the script from the command line
- Create a .bat file with just one word ant in it. This does not do any exception handling
- Open the control panel -> System and Security -> Power Options and make sure that the computer never sleeps option is set (you need admin rights)
- Open the control panel -> System and Security -> Administrative Tools -> Task Scheduler
- Create a new task and navigate to the path of the .bat file in the Actions Tab under start a program
- Make sure the "Start In (Optional)" field has the absolute path to the file (without quotes)
- The final change is assigning the "Full Control" permission explicitly to .bat file for the account running the task.
Note:
- Make sure that the task is running as an account that has explicit "Full access" permissions to all these things: The .bat file itself, the folder containing the .bat file, and the target files/folders that are affected by the .bat script. Inherited permissions didn't seem to work for me.
- Make sure that the account running the task is a member of the local "administrators" group for this machine
- Make sure that the task is set to "run whether logged on or not"
- The Task should run successfully with expected output when you right-click on the task and select "run" If it does that then it will run successfully when you are logged off.
Comments
Post a Comment