Link to home
Start Free TrialLog in
Avatar of jpfulton
jpfulton

asked on

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.
Avatar of Lee W, MVP
Lee W, MVP
Flag of United States of America image

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.
Avatar of jpfulton
jpfulton

ASKER

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.
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).
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?
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.
ASKER CERTIFIED SOLUTION
Avatar of Lee W, MVP
Lee W, MVP
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.