none
Batch file not running in task scheduler

    Question

  • Hi

    Windows Server 2012 with Essentials role.

    I am running a batch file in a task but it does not run. I get this;

    Task Scheduler successfully completed task "\FullDBBackup" , instance "{af570e8c-602b-45f6-80a4-b2d49f8b47d0}" , action "C:\Windows\SYSTEM32\cmd.exe" with return code 2147942401.

    I have tried various things;

    • Made sure task is run with highest privileges.
    • Added path in 'Start In'.
    • Added /c in 'Add arguments'.
    • Added C:\Windows\system32\cmd.exe before batch name.
    • Used UNC instead of shared drive.

    This is the first time I have had issue with task scheduler and is very intriguing. What am I doing wrong?

    Thanks

    Regards

    Friday, October 06, 2017 3:52 PM

All replies

  • Hi,

    Please try to disable UAC temporarily, then, manually start the task and check the result. 

    Besides, whether this Batch file will run when manually start it on your server(double click it to run).

    Best Regards,
    Eve Wang

    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Monday, October 09, 2017 9:43 AM
    Moderator
  • Hi Eve

    UAC is already disabled. Manually running the task returns error 0x1. Screen below.

    Thanks

    Regards

    Tuesday, October 10, 2017 3:42 PM
  • Hi,

    I am having the exact same problem - Task says it ran and completed successfully but the job wasn't done. Run the batch file directly and it works, just won't via task scheduler.


    • Edited by naellis Thursday, October 12, 2017 10:16 AM
    Thursday, October 12, 2017 10:15 AM
  • Hi

    Batch file path included a share. When I gave direct path it worked for me.

    Thanks

    Regards


    • Edited by Y a h y a Thursday, October 26, 2017 2:02 PM
    Wednesday, October 25, 2017 3:52 PM
  • Hi,

    Please check below options in Task general tab:
    1. Select option “Run whether user is logged on or not”.
    2. “Configure for" is set as current OS version.

    Best Regards,
    Eve Wang

    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Monday, October 30, 2017 3:04 AM
    Moderator
  • Same problem here...

    I have tried to change:

    1) "When running the task, use following user account" (SYSTEM, Local admin, etc)

    2) Run whether user is logged on or not (do not store pass)

    3) Run with higherst privileges

    4) Configure for (win7 vs Vista)

    Only if I set domain administrator (domain\administrator) as "RunAs" user, script start and complete successfully.


    • Edited by SYFS Tuesday, October 31, 2017 8:39 PM
    Tuesday, October 31, 2017 8:17 PM
  • Hi,

    >Only if I set domain administrator (domain\administrator) as "RunAs" user, script start and complete successfully.
    If it runs successfully with admin permission, it seems that it permission relate. Also, have you tried another simple scripts file and confirm that if it is scripts relate, or, some scripts need special permission? 

    Best Regards,
    Eve Wang

    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Tuesday, November 07, 2017 7:50 AM
    Moderator
  • If you are running as a 'standard user' have you made sure they have the logon as batch job privilege?

    You can make them a member of Backup Operators group for that.


    Robert Pearman Cloud & Datacentre MVP
    @titlerequired | LinkedIn | Google+
    Facebook | Windows Server Essentials.com

    Friday, November 10, 2017 8:53 AM
    Moderator