Task Scheduler Woes


  1. Posts : 40
    W10 Home
       #1

    Task Scheduler Woes


    Hi

    I am having trouble running scripts using Task Scheduler. My computer freezes up when the task is run: I have it set to trigger at a specific time, it is triggered but then freezes. I have done a ton of research and have tried multiple options to try to fix this but I can't get it. I used to run these scripts on my W7 machine and they worked fine with Task Scheduler. I have these tasks to run in the early morning while I am sleeping. More info:

    1. My user account has admin privileges. I have also created a new user account with admin privileges.
    2. I recreated the task from scratch.
    3. The scripts work fine when I run them manually.
    4. The task runs fine when I run it manually.
    5. I have tried different formats for inputting info into the Edit Actions dialog box - use/don't use parenthesis, tried using command prompt to run the script.

    Does anyone have any ideas?

    Thank you.
    version 21h1 build 19043.1288
      My Computer


  2. Posts : 16,950
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #2

    1 I suggest you post
    - The task definition[s] - It's up to you but the easiest method is probably by posting the xml file created when you right-click on a task & select Export.
    - The script[s]

    2 If you have set the task[s] to run whether or not the user is logged in then try changing them to run only when the user is logged in.

    3 Check that you are logged in when the task[s] run.

    4 What "freezes"? Exactly what do you see happening & not happening?

    5 If you saved the task definitions from Windows 7 then compare them with your current ones.

    6 See if anything in this recent thread helps you - Scheduled task - TenForums

    All the best,
    Denis
      My Computer


  3. Posts : 40
    W10 Home
    Thread Starter
       #3

    Denis

    Thanks for your reply. I have posted the .xml file below of a batch file I am trying to run with Task Scheduler. Here are some replies to your questions:

    1. I have tried running TS with the option Run Whether User is Logged On checked and unchecked. I have verified that the User is logged on and is an administrator.

    2. What do I mean by freeze? What happens is that I have my laptop in a sleep state. TS triggers and my laptop wakes up but after the task is (supposedly) complete, the laptop does not go back to sleep. It stays powered up - I can see by the status lights on the side. When I open the lid, the laptop is unresponsive other than the keyboard back light comes on. Other than that, nothing. I have to hold the power button for 5 seconds or so to get it to turn off. Then when I turn it back on, I find that TS didn't run even though it was triggered (laptop came out of sleep state). However, sometimes TS shows that it ran (The task was successfully completed) but not always. Sometimes it doesn't show that it has triggered even though the laptop woke up. It is inconsistent.

    Here is my task definition:

    Thank you.

    <?xml version="1.0" encoding="UTF-16"?>
    <Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
    <RegistrationInfo>
    <Date>2021-11-06T11:58:05.9592708</Date>
    <Author>DAVES-LAPTOP\Dave</Author>
    <Description>Backs up your Garmin map files, JMRI files, Dave's Folder, Music, all pst files (2 locations), Mozilla Firefox bookmarks and your desktop. This is done by using scripts you created that are stored in your backup folder. Don't move the scripts out of the folder they are in. MAKE SURE OUTLOOK IS CLOSED OTHERWISE THIS TASK WILL GET HUNG UP! Also, backs uo your Garmin files (routes, tracks and waypoints you created).</Description>
    <URI>\Backup_SECONDARY_New</URI>
    </RegistrationInfo>
    <Triggers>
    <CalendarTrigger>
    <StartBoundary>2021-11-06T10:30:00</StartBoundary>
    <ExecutionTimeLimit>PT1H</ExecutionTimeLimit>
    <Enabled>true</Enabled>
    <ScheduleByDay>
    <DaysInterval>1</DaysInterval>
    </ScheduleByDay>
    </CalendarTrigger>
    </Triggers>
    <Principals>
    <Principal id="Author">
    <UserId>S-1-5-21-XXX-XXX-3686626870-1005</UserId>
    <LogonType>InteractiveToken</LogonType>
    <RunLevel>HighestAvailable</RunLevel>
    </Principal>
    </Principals>
    <Settings>
    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
    <AllowHardTerminate>true</AllowHardTerminate>
    <StartWhenAvailable>true</StartWhenAvailable>
    <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
    <IdleSettings>
    <StopOnIdleEnd>true</StopOnIdleEnd>
    <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <AllowStartOnDemand>true</AllowStartOnDemand>
    <Enabled>true</Enabled>
    <Hidden>false</Hidden>
    <RunOnlyIfIdle>false</RunOnlyIfIdle>
    <WakeToRun>true</WakeToRun>
    <ExecutionTimeLimit>PT20M</ExecutionTimeLimit>
    <Priority>7</Priority>
    <RestartOnFailure>
    <Interval>PT1M</Interval>
    <Count>3</Count>
    </RestartOnFailure>
    </Settings>
    <Actions Context="Author">
    <Exec>
    <Command>Dave's_Folder_Backup.bat</Command>
    <WorkingDirectory>C:\Users\Dave\Dave's_Folder\Backup_Info_Task_Scheduler_Info\Backup_Scripts\Backup_ SECONDARY\</WorkingDirectory>
    </Exec>
    <Exec>
    <Command>Desktop_Backup.bat</Command>
    <WorkingDirectory>C:\Users\Dave\Dave's_Folder\Backup_Info_Task_Scheduler_Info\Backup_Scripts\Backup_ SECONDARY\</WorkingDirectory>
    </Exec>
    <Exec>
    <Command>Gmail_pst_File_Backup.bat</Command>
    <WorkingDirectory>C:\Users\Dave\Dave's_Folder\Backup_Info_Task_Scheduler_Info\Backup_Scripts\Backup_ SECONDARY\</WorkingDirectory>
    </Exec>
    <Exec>
    <Command>Music_Backup.bat</Command>
    <WorkingDirectory>C:\Users\Dave\Dave's_Folder\Backup_Info_Task_Scheduler_Info\Backup_Scripts\Backup_ SECONDARY\</WorkingDirectory>
    </Exec>
    <Exec>
    <Command>Garmin_Map_Files_Backup.bat</Command>
    <WorkingDirectory>C:\Users\Dave\Dave's_Folder\Backup_Info_Task_Scheduler_Info\Backup_Scripts\Backup_ SECONDARY\</WorkingDirectory>
    </Exec>
    <Exec>
    <Command>JMRI_Backup.bat</Command>
    <WorkingDirectory>C:\Users\Dave\Dave's_Folder\Backup_Info_Task_Scheduler_Info\Backup_Scripts\Backup_ SECONDARY\</WorkingDirectory>
    </Exec>
    <Exec>
    <Command>sleep.bat</Command>
    <WorkingDirectory>C:\Users\Dave\Dave's_Folder\Backup_Info_Task_Scheduler_Info\Backup_Scripts\</WorkingDirectory>
    </Exec>
    </Actions>
    </Task>
      My Computer


  4. Posts : 16,950
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #4

    Your description of the problem sounds to me more like a sleep problem than anything directly related to the task itself. Do you have any other unexpected Sleep symptoms besides this task?

    Your task definition runs a set of 7 batch files. Have you tried substituting just a single one [a fairly innocuous one, such as something like Dir >A:\TestResult.txt] as a final proof that the task is behaving itself so the problem must lie elsewhere?
    Have you tried omitting the final one sleep.bat? Perhaps it is causing the sleep problem.
    Personally, I always disable the StopOnIdleEnd setting.

    Do you know that you can insert a few lines of code in a batch file to escape if Outlook is running? For example,
    Code:
    set TestAppl=outlook.exe
    tasklist | find /i "%TestAppl%" >nul || GoTo OutlookNotRunning
    GoTo EndOfBatchFile
    
    :OutlookNotRunning
    :: do the batch file's actions
    
    :EndOfBatchFile
    Pause to check during testing

    All the best,
    Denis
    Last edited by Try3; 11 Nov 2021 at 15:28.
      My Computer


  5. Posts : 40
    W10 Home
    Thread Starter
       #5

    Hi Denis. Thank you for your help. I have the same issue whether i include the sleep.bat or not. I agree that it doesn’t appear that task scheduler is the problem. I can manually run the tasks fine and, if I set the task’s timer to trigger while I have the laptop on, it works fine. Sleep.bat included or not. The problem occurs when I have the laptop sleeping. I wonder if I need to add a delay timer at the start of my bat files? The idea would be to give the laptop time to ‘wake up’ before starting my bat files. Who knows? Worth a try.

    I did have a problem with my laptop freezing up while not using task scheduler. I found the problem was that my power setting was set to turn the laptop off after a certain amount of time. After turning this off, I don’t have that problem anymore. Btw, I have hibernate turned off.

    If you have any suggestions on trying to diagnose this problem further I would certainly appreciate it.

    Thank you. Dave.
      My Computer


  6. Posts : 16,950
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #6

    jibebuoy said:
    I did have a problem with my laptop freezing up while not using task scheduler. I found the problem was that my power setting was set to turn the laptop off after a certain amount of time. After turning this off, I don’t have that problem anymore.
    Dave,

    If it froze up when attempting to sleep /hibernate or when resuming then I'd suggest reinstalling the display driver[s] but if this was ages ago then it might be entirely unrelated. But if, as you say, it was set to turn off completely then I don't see any connection to the current problem.

    Intermittent faults can be real pigs to diagnose.
    Sleep problems can be real pigs to diagnose.

    I do not think adding a delay to the batch files will make any difference. Your observations indicate a sleep transition issue not a batch-file-running-incorrectly issue.

    I suggest further testing the idea that it is the wakeup from sleep that is the problem by creating another task that wakes it up.
    - Just run a simple task such as Dir >A:\TestResult.txt so the file's created time will tell you when it ran even if you end up having to force the computer off once more to get it running afterwards.
    - Clear the entry in the task definition's Settings tab - Run task as soon as possible after a scheduled start is missed. This will help to avoid misinterpretation of results.
    If this task also goes wrong then you can home in on the sleep transition being the problem.

    The next test could be to create a new user account to see if it suffers from the problem.
    The next test after that could be to see what happens in Safe mode.


    Denis
      My Computer


  7. Posts : 40
    W10 Home
    Thread Starter
       #7

    Denis. Just to close the loop, it appears that I have solved my problem. I sure hope so. I think that my nvidia graphics driver was causing my laptop freeze/crash issue. By disabling the nvidia driver my task scheduler tasks work fine in the middle of the night. I don't wake up to a frozen laptop in the morning.

    I think I had multiple problems occurring at the same time. Another thing I did was change my power setting so the laptop never turns off. I only allow it to sleep. I have hibernate turned off as well.

    Fingers crossed but I think I have a more stable system now with the changes I made.

    Thanks,

    Dave
      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 16:57.
Find Us




Windows 10 Forums