Why isn't my Scheduled Task running a batch script?

7,517

Solution 1

I wonder if you aren't running into the problem of CMD.EXE not being readable by non-Administrator users when not running as "INTERACTIVE" (or "BATCH" or "SERVICE"). This is a a new default in Windows Server 2003. Take a look at this Microsoft KB article for some details.

Solution 2

Soudns like your issue is with 7zip itself, I actually have a very similar process setup myself except I am running the scheduled task as a System User with Admin credentials. As FortyPoundHead states the exit codes are going to be very instrumental in resolving this. Also, I would add some logging to your batch file to see where it fails, to see if it receives an error with 7zip etc. Without some kind of logging you are going to have a hrad time troubleshooting this issue.

Solution 3

Charles is dead-on with the logging, but Process Monitor from the Sysinternals suite might be useful for troubleshooting, as well.

Solution 4

Are you setting the task to run with correct user credentials? What are the completion codes (Last Run Result) for the task in Task Scheduler? You might see 0x2, 0x40010004, or some such.

Share:
7,517

Related videos on Youtube

One Monkey
Author by

One Monkey

Updated on September 17, 2022

Comments

  • One Monkey
    One Monkey over 1 year

    OS: Windows 2003 Server

    Setup: The batch file basically uses 7zip to zip up a few files into a location ready for uploading into an offsite location via FTP. I have run the batch file as myself and it has worked perfectly. It takes about two hours to zip the files.

    I have applied full permissions on the relevant folders to the user account (a non-System user account that I created for this job) that will be performing the scheduled task. I have set the batch file to be runnable by non-administrators. I have made sure that the user has access to all relevant folders and files and is allowed to run 7Zip. I have given the user account permission to read and execute the scheduled task.

    Symptoms: If I right-click the Scheduled Task and select Run three events appear in the Security log showing the User is logging in, and then almost instantly logging out. No other exceptions or errors appear. The expected DOS window does not even flicker into my field of vision. If I run the batch manually then the date accessed on 7zip updates with when the batch started running. When the scheduled task is selected to run it doesn't.

    What am I doing wrong?

  • jgoldschrafe
    jgoldschrafe over 13 years
    +1 for logging, which is so sensible that nobody ever does it.
  • One Monkey
    One Monkey over 13 years
    Thanks to all but as the KB fix suggested was simple to test I tried it and it worked a treat. So specific thanks go to Evan. Lifesaver.
  • Spence
    Spence over 13 years
    My psychic powers pay off again... >smile< The first time I ran into this one I was a bit perplexed. That change in permission on CMD.EXE really threw me for a loop.