Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The given template to create a Task didn't work properly #86

Open
Delikt opened this issue Apr 13, 2022 · 0 comments
Open

The given template to create a Task didn't work properly #86

Delikt opened this issue Apr 13, 2022 · 0 comments

Comments

@Delikt
Copy link

Delikt commented Apr 13, 2022

Description

require 'win32/taskscheduler'
include Win32

ts = TaskScheduler.new

# Create a trigger that starts on April 25, 2014 at 11:05 pm. The trigger
# will run on the first and last week of the month, on Monday and Friday,
# in the months of April and May.
#
trigger = {
  :start_year   => 2014,
  :start_month  => 4,
  :start_day    => 25,
  :start_hour   => 23,
  :start_minute => 5,
  :trigger_type => TaskScheduler::MONTHLYDOW,
  :type => {
    :weeks        => TaskScheduler::FIRST_WEEK | TaskScheduler::LAST_WEEK,
    :days_of_week => TaskScheduler::MONDAY | TaskScheduler::FRIDAY,
    :months       => TaskScheduler::APRIL | TaskScheduler::MAY
  }
}

ts.new_work_item('my_notepad', trigger)
ts.application_name = 'notepad.exe'
ts.activate('my_notepad')

The template just create for the first Week of Month the scheduled Task but not for the last Week.

In my case i can use this template to create a Task but i need it triggered only in the last Week. If i modify the Template for my use case:

  :trigger_type => TaskScheduler::MONTHLYDOW,
  :type => {
    :weeks        => TaskScheduler::LAST_WEEK,

It didn't care and still create the Trigger in the first week!?
Windows 10 and later x64 - VMware Workstation 16 Player (Non-commercial use only)_001

Gem Version

win32-taskscheduler 2.0.4

Windows Version

Microsoft Windows [Version 10.0.19044.1466]

Replication Case

Just try the given template and take a look on the Trigger under the Windows Task scheduler GUI

i-s-o added a commit to i-s-o/win32-taskscheduler that referenced this issue Jun 16, 2022
The name of the weeks of the month option was changed in chef#16 from :weeks to :weeks_of_month to mimic the Task Scheduler API, but the README was not updated to reflect this change. Fixes chef#86
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant