Monday

Schedule a Java ANT program on windows



This is the easiest way to schedule a ANT build.xml script that you want to Run on any machine

  1. Make sure you can navigate to the path where you have the build.xml stored and run the ant command from command prompt
  2. Once confirmed that you are able to run the script from the command line
  3. Create a .bat file with just one word ant in it. This does not do any exception handling
  4. Open the control panel -> System and Security -> Power Options  and make sure that the computer never sleeps option is set (you need admin rights)
  5. Open the control panel -> System and Security -> Administrative Tools -> Task Scheduler
  6. Create a new task and navigate to the path of the .bat file in the Actions Tab under start a program
  7. Make sure the "Start In (Optional)" field has the absolute path to the file (without quotes)
  8. 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.

No comments:

Post a Comment