Task Scheduler and Bat File Problem


  1. Posts : 7
    Windows 10
       #1

    Task Scheduler and Bat File Problem


    Hi,

    Not sure which forum to post this in, but hopefully someone has some insight and can help me with this.

    I have a simple .bat file that stops my media server, creates an archive of a folder (for backup purposes), and then starts the media server again. It works perfectly if I double click the .bat file, or if I run the bat file from the command prompt.

    When I run it from Windows Task Scheduler, however, it does not work properly. The media server does not shut down. If I look in the task manager, though, I see that the archiving program has started. It is difficult to see what is happening because, unlinke when running this in CMD, when it is run from the task scheduler it produces no output to see if there is an error message.

    Why would it run differently from the task scheduler than when I simply double click the .bat file? I have chosen to run it from the same user account, and also selected "run with highest privileges."

    Here is the bat file. The first line stops the media server. The second line runs the archiving process (using 7zip). The third line starts the media server again. Again, it works perfectly if I simply double click the bat file.

    Code:
    @echo off
    
    taskkill /im "plex media server.exe"
    
    7za u C:\plexbackup.7z C:\plexdata -mx0 -up1q0r2x1y2z1w2
    
    "C:\Program Files (x86)\Plex\Plex Media Server\plex media server.exe"
    Anyone have insight?

    Thanks.
      My Computer


  2. Posts : 353
    Multi-Boot W7_Pro_x64 W8.1_Pro_x64 W10_Pro_x64
       #2

    In Task Scheduler Enable All Tasks History
    Run the scheduled task
    Refresh, and look at the History tab for that task.
    Look at each entry in history and see if you can find an error message/code for any step in the task run.
      My Computer


  3. Posts : 486
    Windows 10x64 17713
       #3

    If you run it with standard privileges it should display a console window and you should be able to see any error messages.
      My Computer


  4. Posts : 7
    Windows 10
    Thread Starter
       #4

    I solved the problem by disabling the feature "run whether the user is logged on or not." With that disabled the batch script runs as it should and the output is visible in the command shell.
      My Computer


  5. Posts : 830
    Windows 10 Pro 21H2
       #5

    I have a problem with the batch file still "Running" in Task Scheduler even after closing the program and have tried both Exit and EOF to end it. The only way to stop it is select "End" in Task Scheduler.

    Code:
    Start "" "D:\Programs\theWord\theword-6.0.0.1517.exe"
    
    Rem Exit
    GOTO: EOF
    EDIT: I just tried to use a batch file, shortcut and a direct link to the program and all of them continue running even after shutting the program down.

    EDIT2: Changed time on PC and everything worked as should, but not when using "Run" in Task Scheduler which seems to have a bug.
    Last edited by rdwray; 12 Feb 2021 at 07:42.
      My Computer


  6. Posts : 11,654
    Windows 10 Home x64 Version 21H2 Build 19044.1776
       #6

    rdwray said:
    I have a problem with the batch file still "Running" in Task Scheduler even after closing the program and have tried both Exit and EOF to end it. The only way to stop it is select "End" in Task Scheduler.
    Task scheduler is a real sod in this respect. It refreshes itself to show when a task starts running but does not refresh when it finishes.
    - So the task might have finished but Task scheduler will not show that fact of its own accord.
    - If you want TS to show that it has finished you will have to manually refresh the Task scheduler view.

    Denis
      My Computer


  7. Posts : 830
    Windows 10 Pro 21H2
       #7

    Try3 said:
    Task scheduler is a real sod in this respect. It refreshes itself to show when a task starts running but does not refresh when it finishes.
    - So the task might have finished but Task scheduler will not show that fact of its own accord.
    - If you want TS to show that it has finished you will have to manually refresh the Task scheduler view.

    Denis
    Some lessons are hard learned.
      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:03.
Find Us




Windows 10 Forums