Windows 7 scheduled task returns 0x2

windowswindows 7windows task scheduler

I have identical scheduled tasks running in Windows XP Pro and Windows 7. The XP Pro one runs fine, the Windows 7 one always returns 0x2 (which means, "The system cannot find the file specified"; however, executing from the command line is no problem) in the Last Run Result column of the Task Scheduler UI.

The scheduled task executes a .bat file daily. The .bat file contains a call to execute a Perl script. As I stated in the previous paragraph, it executes under XP without any trouble but under Windows 7, no dice.

The task under Windows 7 is set to "run whether the user is logged on or not." In this case it is me, I am the only user of the system. It is also set to "Run with highest privileges." And it is not hidden. The .bat file executes perfectly well from the command line – it calls the Perl script as expected and the Perl script does its thing.

I have searched far and wide looking for an appropriate answer to this issue. So far I have found nothing. What the devil is going on with this Win7 scheduled task? I am ready to pull my hair out.

Best Answer

I had this issue as well. 0x2 from task scheduler seemed to say it couldn't find the batch file. This was false - I added some pipe arrows (>>) to output my batch file to a logfile, then ran the scheduled task.

Despite getting a 0x2 in Task Scheduler, I found the batch file had actually run, but had encountered an error (which showed up in the logfile).

Another thing to try is running the task as SYSTEM or NETWORK SERVICE instead.