batch file from scheduled task returns code 2147942401

The error codes for Task Scheduler are listed as hexadecimal at msdn, and your code 2147942401 converts to hex as 0x80070001 (which is not listed there), but this superuser describes it as an “Illegal Function”. He fixed his problem by using “the simplest task scheduler settings and now it works”. I note that he only runs his task when the user is logged in, so he doesn’t need “Log on as a batch job”.

If you want to run the batch job when you’re not logged in, you need a special privilege called “Log on as a batch job”. Note that there is also a “DENY log on as a batch job” privilege, which you wouldn’t want.

From Social Technet, you can assign that privilege with

  • Type in secpol.msc /s
  • Select “Local Policies” in MSC snap in
  • Select “User Rights Assignment
  • Right click on “Log on as batch job” and select Properties
  • Click “Add User or Group“, and include the relevant user.

Your task calls a network resource. These powershell scripters recommend bringing those resources to your local machine to eliminate any chance of network/connectivity/permissions issues … but that may not always be appropriate or practical.

Leave a Comment