Sha256: 4b126b9acd4131c2fe0e890e944022ae63c69a84d4931dfb54ba3d5360861a84

Contents?: true

Size: 1.39 KB

Versions: 5

Compression:

Stored size: 1.39 KB

Contents

#######################################################################
# taskscheduler_example.rb
#
# A test script for general futzing. You can run this example via the
# 'example' rake task.
#
# Modify as you see fit.
#######################################################################
require 'win32/taskscheduler'
require 'fileutils'
require 'pp'
include Win32

puts 'VERSION: ' + TaskScheduler::VERSION

ts = TaskScheduler.new

trigger = {
	"start_year" 	=> 2009,
	"start_month" 	=> 4,
	"start_day"   	=> 11,
	"start_hour"	=> 7,
	"start_minute"	=> 14,
	"trigger_type"	=> TaskScheduler::DAILY,
	"type"			=> { "days_interval" => 1 }
}

unless ts.enum.grep(/foo/).length > 0
	ts.new_work_item("foo", trigger)
	ts.application_name = "notepad.exe"
	ts.save
	puts "Task Added"
end

ts.activate("foo")
ts.priority = TaskScheduler::IDLE
ts.working_directory = "C:\\"

puts "App name: " + ts.application_name
puts "Creator: " + ts.creator
puts "Exit code: " + ts.exit_code.to_s
puts "Flags: " + ts.flags.to_s
puts "Max run time: " + ts.max_run_time.to_s
puts "Next run time: " + ts.next_run_time.to_s
puts "Parameters: " + ts.parameters
puts "Priority: " + ts.priority.to_s
puts "Status: " + ts.status
puts "Trigger count: " + ts.trigger_count.to_s
puts "Trigger string: " + ts.trigger_string(0)
puts "Working directory: " + ts.working_directory
puts "Trigger: "

pp ts.trigger(0)

ts.delete("foo")
puts "Task deleted"

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
win32-taskscheduler-1.0.10 examples/taskscheduler_example.rb
win32-taskscheduler-1.0.9 examples/taskscheduler_example.rb
win32-taskscheduler-1.0.2 examples/taskscheduler_example.rb
win32-taskscheduler-0.3.1 examples/taskscheduler_example.rb
win32-taskscheduler-0.3.0 examples/taskscheduler_example.rb