Task Scheduler Error 0x1--Running Bat File Daily


  1. Posts : 186
    Windows 10 Pro x64 21H2
       #1

    Task Scheduler Error 0x1--Running Bat File Daily


    I have a bat file that I'm trying to setup to run daily; however, sometimes when task scheduler runs the bat file, it's giving a 0x1. If I run the bat file manually or copy/paste the command into command prompt, it works. I have the bat file setup to run with the highest privilege and to run whether the user is logged in or not. Here's the command that I'm trying to run from within the bat file:
    Code:
    hostlist-compiler -c C:\Users\{username}\Documents\AdGuard\config\aiofireboggreen.json -o C:\Users\{username}\Documents\GitHub\AIO-Firebog-Blocklists\aiofireboggreen.txt && hostlist-compiler -c C:\Users\{username}\Documents\AdGuard\config\aiofirebogblue.json -o C:\Users\{username}\Documents\GitHub\AIO-Firebog-Blocklists\aiofirebogblue.txt && hostlist-compiler -c C:\Users\{username}\Documents\AdGuard\config\aiofirebog.json -o C:\Users\{username}\Documents\GitHub\AIO-Firebog-Blocklists\aiofirebog.txt
    I added the timeout at the end to see if I could read what was happening but task scheduler closed the cmd window anyway.
      My Computer


  2. Posts : 18,034
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
       #2

    Hello @TONPumper,

    Does using a Pause instead of the Timeout work in CMD Prompt ?
      My Computer


  3. Posts : 186
    Windows 10 Pro x64 21H2
    Thread Starter
       #3

    Hi Paul,

    I don't intend on keeping the time command in the bat file. I only did that for a test. I removed it from my original post to reflect the code that isn't working when ran from task scheduler.

    Thank you for the quick reply.

    EDIT: It ignored the PAUSE command too. I manually ran the scheduled task and it worked fine. I'm using Adguard Host Compiler to make DNS blocklists, so there are many sources that it's pulling from. If one of them fails, the whole operation cancels. It's just odd to me that I can watch it fail, run it manually, and have it work fine only seconds later.
    Last edited by TONPumper; 26 Mar 2023 at 18:00.
      My Computer


  4. Posts : 186
    Windows 10 Pro x64 21H2
    Thread Starter
       #4

    Couple of things I did--not sure what fixed it:

    • Set task to run with high priviledge whether the user is logged in or not
    • Changed the file path to be just the file name and extension
    • Added the full file path without the file name in the Start in section
    • Turned off the option in GitHub Desktop to periodically check for updates
      My Computer


  5. Posts : 844
    Windows 7
       #5

    Task Scheduler Error 0x1 is insufficient privilege. It's probably a race condition caused by your GitHub sync, which is locking one of the JSON files.

    You could test this by running the same script in an infinite loop, and manually forcing GitHub to sync while it's going. If it fails because you're syncing, you will know why. The blocklists are several MB in size, so it's possible for the sync to finish in the few seconds before you re-run the script.
      My Computer


  6. Posts : 17,049
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #6

    TONPumper said:
    task scheduler closed the cmd window anyway.
    TONPumper said:
    EDIT: It ignored the PAUSE command too.
    Task scheduler does not close command windows or respond to Pause commands. It has no function for doing so nor any interest in doing so. All Task scheduler does is launch things.

    Whatever is happening, it is being caused by the contents of your command.
    The command is apparently crashing before it reaches the Pause command.

    Personally, in order to understand what was happening after launch, I would rejig the three commands into three separate lines [as a batch file] with a Pause command in-between each one & one at the start & another at the end so I could see which command was failing when it was launched by TS.
    Code:
    Pause at start just to check the damn thing is being launched at all
    hostlist-compiler -c C:\Users\{username}\Documents\AdGuard\config\aiofireboggreen.json -o C:\Users\{username}\Documents\GitHub\AIO-Firebog-Blocklists\aiofireboggreen.txt 
    Pause after command 1
    hostlist-compiler -c C:\Users\{username}\Documents\AdGuard\config\aiofirebogblue.json -o C:\Users\{username}\Documents\GitHub\AIO-Firebog-Blocklists\aiofirebogblue.txt 
    Pause after command 2
    hostlist-compiler -c C:\Users\{username}\Documents\AdGuard\config\aiofirebog.json -o C:\Users\{username}\Documents\GitHub\AIO-Firebog-Blocklists\aiofirebog.txt
    Pause at the end, after command 3


    Denis
      My Computer


  7. Posts : 17,049
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #7

    TONPumper said:
    Couple of things I did--not sure what fixed it:
    The fault is fixed?

    Denis
      My Computer


  8. Posts : 186
    Windows 10 Pro x64 21H2
    Thread Starter
       #8

    Try3 said:
    The fault is fixed?

    Denis
    Indeed it is. It has ran perfectly now.
      My Computer


  9. Posts : 844
    Windows 7
       #9

    Another idea is keep Desktop's sync disabled, but use GitHub's command-line to force a sync in the batch file.
    Code:
    call gh repo sync
    hostlist-compiler -c C:\Users\{username}\Documents\AdGuard\config\aiofireboggreen.json -o C:\Users\{username}\Documents\GitHub\AIO-Firebog-Blocklists\aiofireboggreen.txt && hostlist-compiler -c C:\Users\{username}\Documents\AdGuard\config\aiofirebogblue.json -o C:\Users\{username}\Documents\GitHub\AIO-Firebog-Blocklists\aiofirebogblue.txt && hostlist-compiler -c C:\Users\{username}\Documents\AdGuard\config\aiofirebog.json -o C:\Users\{username}\Documents\GitHub\AIO-Firebog-Blocklists\aiofirebog.txt
    Attached Thumbnails Attached Thumbnails Task Scheduler Error 0x1--Running Bat File Daily-2023_03_30_17_03_161.png  
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd
All times are GMT -5. The time now is 08:16.
Find Us




Windows 10 Forums