Windows 10: Windows 10 Task Scheduler: How to program non-routine trigger

Discus and support Windows 10 Task Scheduler: How to program non-routine trigger in Windows 10 Support to solve the problem; Hi I am trying to set up a task to be triggered on the second day of every month, but not if that day is a Saturday. Can anyone help please? 93227 Discussion in 'Windows 10 Support' started by Old Novice, Sep 11, 2017.

  1. Windows 10 Task Scheduler: How to program non-routine trigger


    Hi
    I am trying to set up a task to be triggered on the second day of every month, but not if that day is a Saturday.

    Can anyone help please?

    :)
     
    Old Novice, Sep 11, 2017
    #1
  2. Wim Spaak Win User

    Windows Task Scheduler does not trigger a task, after a PC-restart during the day

    The problem:

    I started my PC before the first Backup4all (my backup program) task schedule (at 10:00) and during the day all Backup4all backups were made correctly, with an interval of the programmed 1 hour.

    At 15:45 I restarted my PC. No Backup4all backups were made from the moment the PC was restarted.

    At 16:13 I made a screendump of the Windows Task Scheduler (see below).
    Windows 10 Task Scheduler: How to program non-routine trigger [​IMG]
    You
    can see in the attachment that Windows Task Scheduler updates the Next Run Time at about 16:00, but Last Run Time remains on the one before PC-restart.

    So Backup4all is not triggered by the Windows Task Scheduler to backup.

    At 16:33 a made a screendump of the Windows Task Scheduler screen again and you see in the blue frame that the Next Run Time is updated, but Last Run Time is not.

    I also enabled the Windows Task Scheduler History and at 16:33 you see that the last event was from 15:00



    Finally I used the Action "Run" in the Windows Task Scheduler at 17:17 and Backup4all started the backup successfully at 17:17:09.

    Now the Windows Task Scheduler History also shows an event: that the task is completed



    It seems that Windows Task Scheduler triggers the backup job correctly, when the PC is powered-on before the first task schedule time. After a PC restart or a daily power-on after the first backup should be made, the backup program is not triggered by Wimndows
    Task Scheduler anymore.

    I tried this by both the “Run task as soon as possible after a scheduled start is missed" checked and unchecked. In case of a check, the backup tasks are still not triggered by Windows Task Scheduler.

    Does anybody has a solution for this problem, or is it a bug in the Windows Task Scheduler ( the problem started to occur a few month ago).
     
    Wim Spaak, Sep 11, 2017
    #2
  3. Wim Spaak Win User
    Windows Task Scheduler does not trigger a task, after a PC-restart during the day

    Hi Jarius,



    Thank you for your reply.

    • On October 25, 2016, I checked the Windows Task Scheduler settings, according to your advice.
    • The next morning I powered-on my PC at 09:30 and made a screendump of the Task Scheduler at 10:08.

      At that time 2 of my 5 scheduled backup task were triggered conform schedule and the according backups were carried out correctly (see the green framed surfaces in the 10:08 window below)
    • I powered-off my PC at 10:12 and powered it on again at 15:45.


    Windows 10 Task Scheduler: How to program non-routine trigger [​IMG]


    • At 15:50 I made a sreendump of the Task Scheduler window, where was indicated that 3 backup tasks were carried out correctly in the past at about 10:00 (see the green framed surfaces in the 15:50 window in the picture above).
    • At 16:40 I made a screendump again. Now the backup task that were triggered after the first power-on at about 10:00, now were not triggered anymore (the red framed surfaces in the 16:40 window) and the backup task that were not triggered during the first
      power-on, were now triggered correctly at about 16:00 (the green framed surfaces in the 16:40 window).
    • I also made screendumps again at 17:40 and 18:40. In both cases the backup tasks triggered during the first power-on at 9:30 were not triggered anymore and the backup tasks that were not triggered during the first power-on were correctly triggered with
      the scheduled 1 hour interval.


    My conclusion:

    • If my PC is powered-on before the first scheduled backup task, all backup job triggers are carried out conform schedule.
    • After a PC restart the previously triggered backup task are not triggered anymore during the rest of the day.
    • Only backup tasks that were not triggered before the PC restart, are triggered correctly after the PC restart.
    • A manual run of a backup task always result in a correct backup task trigger.


    This must be a bug in the Windows Task Scheduler.



    I hope you will find a solution for this problem.



    Best regards, Wim
     
    Wim Spaak, Sep 11, 2017
    #3
  4. dalchina New Member

    Windows 10 Task Scheduler: How to program non-routine trigger

    Hi, you'll have realised you can't do that directly with te task scheduler, although you can of course start a task on the 2nd day of each month.

    I would create the task so as to launch a small Autohotkey script, which would basically do this:

    Assign today = value representing the current day ; Mon Tue Wed etc
    If today NE Saturday then
    Run the task you want to run ; Executed except on Saturdays
    Exit

    (That's not a script, merely indicates the very simple logic).

    Autohotkey is a well supported free scripting language with a good forum and help file.
    AutoHotkey

    This command would help you obtain a string or number representing the day of the week

    Windows 10 Task Scheduler: How to program non-routine trigger [​IMG]
     
    dalchina, Sep 11, 2017
    #4
  5. cereberus Win User
    You could create a batch file (run daily) that returns day of week, jumps to specific location depending on day of week, then executes what ever command you want (assuming it can be executed from a command line)

    you can download a batch file containing text below

    Microsoft OneDrive - Access files anywhere. Create docs with free Office Online.

    or create own.


    I take no credit for this - it is an amalgamation of several batch files I found on web,

    I tried it and it returns Tue which is today's date.
    --------------------------------------------------------------------------------------------

    @echo
    setlocal enabledelayedexpansion
    set DoW=Sun Mon Tue Wed Thu Fri Sat
    set /a Line=0
    for /f "tokens=1-9" %%a in ('wmic Path Win32_LocalTime Get Day^,DayOfWeek^,Hour^,Minute^,Month^,Quarter^,Second^,WeekInMonth^,Year ^| find /v ""') do (
    set /a Line += 1
    if "!Line!"=="1" (set VarA=%%a&set VarB=%%b&set VarC=%%c&set VarD=%%d&set VarE=%%e&set VarF=%%f&set VarG=%%g&set VarH=%%h&set VarI=%%i)
    if "!Line!"=="2" (set !VarA!=%%a&set !VarB!=%%b&set !VarC!=%%c&set !VarD!=%%d&set !VarE!=%%e&set !VarF!=%%f&set !VarG!=%%g&set !VarH!=%%h&set !VarI!=%%i)
    )
    for %%a in (Month Day Hour Minute Second) do (if !%%a! LSS 10 set %%a=0!%%a!)
    set /a DoWIndex = DayOfWeek + 1
    for /f "tokens=%DoWIndex%" %%a in ("%DoW%") do set DayOfWeekName=%%a
    REM *** At this point, the variables DayOfWeekName, Day, DayOfWeek, Hour, Minute, Month, Quarter, Second, WeekInMonth, and Year are set.
    REM *** Month, Day, Hour, Minute, Second have leading zeros if less than 10.
    echo DayOfWeekName: %DayOfWeekName%

    pause

    if %DayOfWeekName%==Mon goto :mon
    if %DayOfWeekName%==Tue goto :tue
    if %DayOfWeekNamegoto :wed
    if %DayOfWeekName%==Thu goto :thu
    if %DayOfWeekName%==Fri goto :fri
    if %DayOfWeekName%==Sat goto :sat
    if %DayOfWeekName%==Sun goto :sun

    :mon
    :: put your processing here
    echo %DayOfWeekName%
    pause
    exit

    :tue
    :: put your processing here
    echo %DayOfWeekName%
    pause
    exit

    :wed
    :: put your processing here
    echo %DayOfWeekName%
    pause
    exit

    :thu
    :: put your processing here
    echo %DayOfWeekName%
    pause
    exit

    :fri
    :: put your processing here
    echo %DayOfWeekName%
    pause
    exit

    :sat
    :: put your processing here
    echo %DayOfWeekName%
    pause
    exit

    :sun
    :: put your processing here
    echo %DayOfWeekName%
    pause
    exit
     
    cereberus, Sep 11, 2017
    #5
  6. Dear Dalchina and Cereberus

    Thank you both for your suggested solutions for my task scheduling problem.

    When submitting my post, in the interests of brevity I did not mention that the task involved is alreading operating from Task Scheduler under other simpler triggers, and I was just hoping to be able to add an additional trigger.

    However, at Task Scheduler appears to have no facility for subjecting triggers to logical processes, maybe I should look at scripting the whole thing.

    Thank you also Dalchina for your reference to Autohotkey. I have downloaded it and it looks like a good resource to have.

    You both contributed to alerting me to the possibility of scripting the triggers, for which I am grateful, and although I am not too experienced in scripting I am nonetheless happy to mark my post as solved.
     
    Old Novice, Sep 13, 2017
    #6
  7. dalchina New Member
    Good.. Autohotkey is a remarkable scripting tool. You can use it for
    - very simple scripts (like this one, which should be just 4 or 5 lines at most)
    - writing complete programs
    - manipulating existing Windows - e.g. clicking buttons, testing for presence, closing annoying popups etc etc
    (that's supported by tools which let you inspect many window parameters so you can find the identity of elements in a window)

    Scripts can be run as the source code alone (ahk files) or compiled with 1 click to produce an exe file.

    There is a language sensitive editor to help writing scripts
    SciTE4AutoHotkey Editor
     
    dalchina, Apr 4, 2018
    #7
Thema:

Windows 10 Task Scheduler: How to program non-routine trigger

Loading...
  1. Windows 10 Task Scheduler: How to program non-routine trigger - Similar Threads - Task Scheduler program

  2. Task Scheduler is not triggering

    in Windows 10 Gaming
    Task Scheduler is not triggering: As usual having problems with sheduled tasks.- The task is running on Windows 11- it runs with higher privileges. Admin user with password- it should triggers every minute. The "next run time" is correct but it doesn't trigger. The history is enabled but doesn't giving any...
  3. Task Scheduler is not triggering

    in Windows 10 Software and Apps
    Task Scheduler is not triggering: As usual having problems with sheduled tasks.- The task is running on Windows 11- it runs with higher privileges. Admin user with password- it should triggers every minute. The "next run time" is correct but it doesn't trigger. The history is enabled but doesn't giving any...
  4. Task Scheduler Trigger not working.

    in Windows 10 Gaming
    Task Scheduler Trigger not working.: I am scheduling some jobs to get the reports from Citrix using PowerShell command. In Task scheduler server we have all required PowerShell Module Task run when I execute manually without any issue. When I set time in trigger it wont execute and not history available for...
  5. Task Scheduler Trigger not working.

    in Windows 10 Software and Apps
    Task Scheduler Trigger not working.: I am scheduling some jobs to get the reports from Citrix using PowerShell command. In Task scheduler server we have all required PowerShell Module Task run when I execute manually without any issue. When I set time in trigger it wont execute and not history available for...
  6. task scheduler trigger time

    in Windows 10 Gaming
    task scheduler trigger time: the trigger time cannot be set with a PM. I use 12 hour time format and want a task to run at 7pm and there is no way to add pm or use 24 hour formatAny ideas would be appreciated...
  7. task scheduler trigger time

    in Windows 10 Software and Apps
    task scheduler trigger time: the trigger time cannot be set with a PM. I use 12 hour time format and want a task to run at 7pm and there is no way to add pm or use 24 hour formatAny ideas would be appreciated...
  8. Task Scheduler Task Not Triggering

    in Windows 10 BSOD Crashes and Debugging
    Task Scheduler Task Not Triggering: hi, any reason any task i create is not triggered at the time i set under one-time triggers? i've already tried a windows fresh install, new user account, dism, sfc, moving file to C: drive, checking to see if task scheduler service is set to automatic, checking and...
  9. Task scheduler screenshot trigger?

    in Windows 10 Ask Insider
    Task scheduler screenshot trigger?: So what event would you use for windows task scheduler if your trying to make it so everytime I take a rectangle screenshot with the snipping tool it automatically saves it to a folder? submitted by /u/Pacman042 [link] [comments]...
  10. Scheduled task triggered at wrong time

    in Windows 10 BSOD Crashes and Debugging
    Scheduled task triggered at wrong time: I've created a task which should run every 3rd of a month. The trigger is [ATTACH] <Triggers> <CalendarTrigger> <StartBoundary>2016-11-16T02:00:00</StartBoundary> <Enabled>true</Enabled> <ScheduleByMonth> <DaysOfMonth>...

Users found this page by searching for:

  1. trogger routine windows 10