Scheduled Batch file with icacls command not working -- active directory

I have a Windows computer that nightly receives a backup via rsync (rsync for windows). Those files are all then backed up to crashplan (cloud based backup). The problem is that permissions get screwed up during the rsync process so I have to fix them all. I have a batch file set up to take care of it and I have that run as a scheduled task. The scheduled task runs but the permissions are not fixed but when I manually invoke the batch file it works exactly as needed. Here's my batch file...
icacls "d:\bak_r" /remove:d jpfulton /T > c:\acl_fix_log.txt
icacls d:\bak_r\*.* /reset /t /c /q > c:\acl_fix_log2.txt

Open in new window

Also, my scheduled task is set to run with a user account with administrator priveleges with "run whether user is logged on or not" checked and "run with highest priveleges" checked. The trigger is "daily at 1am" (which is about 3 hours after rsync completes every night).
Why isn't it working? Any help is much appreciated.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Lee W, MVPTechnology and Business Process AdvisorCommented:
Can you run the batch file as the user account outside of the scheduled task?  

Check the Scheduled Tasks event log to see why it's failing.
jpfultonAuthor Commented:
I'm not sure exactly what to look for there. It doesn't say anywhere that it is failing but it does show a result code of (1) or (0x1) which I'm guessing is purely because it doesn't get a response back from the batch file maybe?? Either way there certainly isn't an explanation of what is going wrong. Maybe I'm looking in the wrong place.
Lee W, MVPTechnology and Business Process AdvisorCommented:
Like I said, can you run the batch file outside of the scheduled task.

Look for anything that's NOT informational.  (I JUST has to do this yesterday to get a scheduled task working myself).
Price Your IT Services for Profit

Managed service contracts are great - when they're making you money. Yes, you’re getting paid monthly, but is it actually profitable? Learn to calculate your hourly overhead burden so you can master your IT services pricing strategy.

jpfultonAuthor Commented:
Ahh, I see... and stupid question... So when I run the batch file directly where in event viewer do I see the event log? Isn't that something that needs to be set up?
jpfultonAuthor Commented:
Actually, I just added the directory path to "Start In" and then set a trigger for "One Time" and I waited for it to run. It got result code 0 (0x0) and I checked the resulting permission -- it worked. So I guess I'll see tomorrow morning if it worked then I'll report back.
Lee W, MVPTechnology and Business Process AdvisorCommented:
Go to Event Viewer, Application and Service Logs, Microsoft, Windows, Task Scheduler, Maintenance.

(NOTE: I'm not saying you're guaranteed to find out why it might be failing, but OFTEN it can give you clues if not outright answers).

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jpfultonAuthor Commented:
Figured it out. The original run schedule was every morning at 1am. When I was troubleshooting I would sometimes set about a minute after from when I was working on it just to see if it would work (if it was 1045 when I was troublehsooting, I'd set it to run at 1046 to see what happened). Every time I did this it seemed to work. In looking at the event viewer logs I finally realized that there were a lot of tasks running at that time so I changed my batch file's run time to 130am and it works now. Thanks for the help.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Server 2008

From novice to tech pro — start learning today.