Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have no idea why it is not working in Task Scheduler because if I run the same code in a batch file it works fine?

I am putting the following into task scheduler on a Win2008 R2 machine and I keep getting a 0x1 result back??

C:\Windows\System32\forfiles.exe /p C:\inetpub\logs\LogFiles /s /m *.log /d -30 /c "cmd /c del @file"

Any ideas how I can get task schedular to play ball? I am running this with highest privalidges ticked?

share|improve this question
I am hitting the same problem on multiple Windows 2008 servers with batch files containing forfiles. I am also running with highest privileges. The batch file runs just fine outside of the task scheduler. Sounds like the same problem you are seeing. Have you found a solution to the problem yet? If so, I would be grateful to hear it. Thanks! John. – user90544 Aug 4 '11 at 18:46

A similar BAT works just fine for me when running via task scheduler on my XP machine. I would not focus on the BAT itself and look into the task scheduler. Revise your question to includes the log from task scheduler - you'll probably find an issue with passwords or something. Also, include all the details of the task itself - who it's running as, etc. What do you mean by "I am running this with highest privalidges ticked?"

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.