Windows 10: Task scheduler simply refuses to run a batch script

Discus and support Task scheduler simply refuses to run a batch script in Windows 10 Customization to solve the problem; I know that there have been many different solutions to this problem posted on the internet and various forums, but I have scoured Google for a... Discussion in 'Windows 10 Customization' started by Tinker Alpha, Jun 14, 2019.

  1. Task scheduler simply refuses to run a batch script


    I know that there have been many different solutions to this problem posted on the internet and various forums, but I have scoured Google for a solution to my problem to no avail. My problem appears to be unique (something that at this rate I do not want).

    Now, onto my problem. I have created a scheduled task on task scheduler to change my desktop background image at certain times of the day. I had it call a batch script, which I have confirmed works, to change the background. However, when I run the task or any of the triggers are triggered, I see no background change or cmd window. Yet under "Last Run Result," it says "The operation completed successfully. (0x0)," with the correct trigger/run time. On the other hand, I beg to differ, as the operation did NOT complete successfully :,(. I am out of ideas.


    Things I've tried already (that had not worked):

    1. Have the action call the batch script (directly)

    2. Have the action call a .lnk (shortcut) to the batch script

    3. Have the action call a .vbs (VBScript) to the .lnk (shortcut) to the batch script

    4. Have the action run "C:\Windows\System32\cmd.exe" with an argument of /c "filename.ext" and with a startup location (no quotes) being the path to the script (not including the script)

    5. Have the action run "C:\Windows\System32\cmd.exe" with an argument of /c start "" "filename.ext" and with a startup location (no quotes) being the path to the script (not including the script)

    6. Have the action run "C:\Windows\System32\cmd.exe" with an argument of /c start filename.ext and with a startup location (no quotes) being the path to the script (not including the script)

    7. Have the action run "C:\Windows\System32\cmd.exe" with an argument of /c start C:\(filepath)\filename.ext and without a startup location

    8. Deleted and recreated the task (very painful)

    9. Created the folder Desktop in C:\windows\SysWOW64\config\systemprofile and recreated the task (very painful)

    10. Restarted my computer (in hopes of something magically fixing itself)

    11. Running sfc /scannow dism /online /cleanup-image /restorehealth with in hopes of something corrupted would be uncorrupted


    FYI: Everything I have tried with the actions has been verified on command prompt and work properly.


    My current settings:

    1. Running task under my own user

    2. Run whether user is logged on or not

    3. Run with highest privileges

    4. Configured for Windows 10

    5. 5 different triggers (all of which work, as shown in how the task is correctly triggered)

    6. The action has not worked yet and is mainly what I am tinkering with

    7. Everything under conditions is unchecked (including grayed-out boxes)

    8. Allow task to be run on demand

    9. Run task as soon as possible after scheduled start is missed

    10. If the task fails, restart every: 1 minute and attempt to restart up to 3 times

    11. If the task is already running, then the following rule applies: Do not start a new instance


    Things that have worked:

    loading...

    :)
     
    Tinker Alpha, Jun 14, 2019
    #1

  2. Running a batch script from Windows 10 Task Scheduler

    You're getting a little hung up on the batch script, so lets ignore that part Task scheduler simply refuses to run a batch script :).

    -> This is hardly surprising, seeing that your Subject has the words "batch script" . . .

    If I simply open an elevated command prompt I can reproduce the problem.

    -> This should make it much easier to solve the problem.

    When I call BuildScript.exe from the command prompt, it is able to properly locate the compiler (avr-gcc).

    -> What exact command do you use?

    I just can't seem to access it from makefile scripting... which makes minimal sense.

    -> Did you compare your environmental variables in the two environments?

    set > standard.txt

    set > elevated.txt

    fc standart.txt elevated.text

    It seems like the Task Scheduler calls things at an elevated privilege and for some reason this is bad?


    -> Nope. The Task Scheduler privilege level is totally derived from the account you use to invoke the specific task.
     
    Frederik Long, Jun 14, 2019
    #2
  3. Running a VB Script File Using Windows 10 Task Scheduler

    You can invoke VB scripts through the Task Scheduler, same as batch files or .exe files. What problem do you actually have? What is the script you run? Is it supposed to be interactive?

    There is little difference between cscript.exe and wscript.exe. When you run cscript.exe you will open a black Command Processor window (cmd.exe). With wscript.exe you won't. Furthermore, the instruction wscript.echo will do different things:

    • Under cscript.exe: Write a line of text in the Command Processor window.
    • Under wscript.exe: Generate message box.
    This difference is important for scripts being invoked by the Task Scheduler.
     
    Frederik Long, Jun 14, 2019
    #3
  4. Task scheduler simply refuses to run a batch script

    Running a batch script from Windows 10 Task Scheduler

    You're getting a little hung up on the batch script, so lets ignore that part Task scheduler simply refuses to run a batch script :). That's not the problem. I've changed the Task Scheduler to directly call BuildScript.exe. Furthermore, I think I've learned that I can bypass the Task Scheduler entirely
    and reproduce the problem. If I simply open an elevated command prompt I can reproduce the problem.

    When I call BuildScript.exe from the command prompt, it is able to properly locate the compiler (avr-gcc). When I call BuildScript from the Task Scheduler or an Elevated Command Prompt it can't find the file (avr-gcc) even though it is being referenced
    by absolute path (C:\WinAVR-20100110\bin). I can browse to, and access avr-gcc while in an elevated command prompt, I just can't seem to access it from makefile scripting... which makes minimal sense.

    So I believe the problem comes down to having elevated privileges. It seems like the Task Scheduler calls things at an elevated privilege and for some reason this is bad? I don't understand how having more permissions could be worse.

    I suppose this technically should get a new subject name as it's not strictly speaking a Task Scheduler issue but I'm not entirely sure what to do about that Task scheduler simply refuses to run a batch script :)
     
    James Kazmierczak, Jun 14, 2019
    #4
Thema:

Task scheduler simply refuses to run a batch script

Loading...
  1. Task scheduler simply refuses to run a batch script - Similar Threads - Task scheduler simply

  2. Task scheduler does not perform or run simple script or task

    in Windows 10 Gaming
    Task scheduler does not perform or run simple script or task: I have a problem with the task scheduler that does not run simple phyton script or play mp3 or run a program when scheduling the taskI have try several options but none seems to solve the issue.thank you,thomas...
  3. Task scheduler does not perform or run simple script or task

    in Windows 10 Software and Apps
    Task scheduler does not perform or run simple script or task: I have a problem with the task scheduler that does not run simple phyton script or play mp3 or run a program when scheduling the taskI have try several options but none seems to solve the issue.thank you,thomas...
  4. Task Scheduler - Batch File

    in Windows 10 Gaming
    Task Scheduler - Batch File: I am attempting to use Task Scheduler to run a batch file automatically every day. I am following instructions that I found on the Web. As far as I can tell I have set up Task Scheduler correctly, the only problem being that it doesn't run! I have uploaded screenshots of the...
  5. Task Scheduler - Batch File

    in Windows 10 Software and Apps
    Task Scheduler - Batch File: I am attempting to use Task Scheduler to run a batch file automatically every day. I am following instructions that I found on the Web. As far as I can tell I have set up Task Scheduler correctly, the only problem being that it doesn't run! I have uploaded screenshots of the...
  6. Running a script on file deletion with task scheduler.

    in Windows 10 Ask Insider
    Running a script on file deletion with task scheduler.: I'm trying to figure out how to run a (python) script whenever any file is deleted with task scheduler. I tried googling but with no success, all I found out was that the event ID for file deletion is 4660 I think, and it's probably under security logs. The problem is that...
  7. Script and task Scheduler

    in Windows 10 BSOD Crashes and Debugging
    Script and task Scheduler: Hello I work for a company with a number of powerful graphic computers on which Windows 10 is installed These computers work 24/7 with 2 engine programs that run intermittently 24/7 but not in parallel. I want to know if it is possible to create a script and use it...
  8. Task Scheduler python script - task starts and completes, but script doesn't run

    in Windows 10 Ask Insider
    Task Scheduler python script - task starts and completes, but script doesn't run: I have a simple script to change my wallpaper that I want to run every 24 hours (separate script that runs fine to download APOD daily). I'm on Windows 10. The script is a .pyw python file. If I run the script using IDLE or simply manually running it by double clicking, it...
  9. Task Scheduler doesn't run script

    in Windows 10 Software and Apps
    Task Scheduler doesn't run script: Hey Microsoft Community, I'm trying to create a task in Task Scheduler that runs a specific script. The issue is that when the task runs (whether I do it manually or if it's scheduled), the script doesn't actually get executed. I know that the script works, and I have tried...
  10. Task Scheduler Script

    in Windows 10 Network and Sharing
    Task Scheduler Script: I want to enable and disable my Ethernet connection at specific times each day. Task Scheduler prompts me for the script identifying the action of enabling or disabling the Ethernet connection. How do I identify these two specific scripts? 75194