2

I have created a windows scheduled task to run an aws command to sync a local folder to an S3 bucket. The task runs a .bat file. If the .bat is ran manually, it runs fine. When it is run via the task I get a 0x1 as the last run result.

Following advice found here, my bat file looks like this:

set AWS_CONFIG_FILE=C:\Users\xxx\.aws\config
set AWS_ACCESS_KEY_ID=xxx
set AWS_SECRET_ACCESS_KEY=xxx
aws s3 sync "C:\my_local_folder" s3://my_bucket --delete

xxx in set AWS_CONFIG_FILE=C:\Users\xxx\.aws\config is the correct path to the .aws\config folder.

My task looks like this:

enter image description here

enter image description here

enter image description here

enter image description here

The account being used is an admin account, is already successfully running other scheduled tasks and the paths in the task are correct.

Community
  • 1
  • 1
TechyGypo
  • 824
  • 1
  • 11
  • 27
  • 1
    Are you sure that the batch file is being executed? Have you tried redirecting output to a file to determine the error being generated? See: [Redirecting Error Messages from Command Prompt: STDERR/STDOUT](https://support.microsoft.com/en-us/kb/110930) – John Rotenstein Nov 26 '16 at 00:11
  • Thank you @JohnRotenstein this is very useful it comes back with `'aws' is not recognized as an internal or external command, operable program or batch file.` Problem solved! I need to put the full path to aws.exe – TechyGypo Nov 26 '16 at 10:10
  • Great! Alternatively, you could put the AWS directory [into your PATH variable](http://superuser.com/questions/737542/how-can-i-add-a-program-path-to-the-windows-environment-variables-for-easy-comma). – John Rotenstein Nov 26 '16 at 17:13

1 Answers1

2

Courtesy @JohnRotenstein's comment about redirecting output, I changed the command to be:

"C:\Program Files\Amazon\AWSCLI\aws.exe" s3 sync "C:\my_local_folder" s3://my_bucket --delete
TechyGypo
  • 824
  • 1
  • 11
  • 27