[Win32utils-devel] Implementing a TaskScheduler#exists? method

Heesob Park phasis at gmail.com
Fri Jun 19 23:42:12 EDT 2009


HI,

2009/6/20 Daniel Berger <djberg96 at gmail.com>:
> Hi,
>
> <snip>
>
>> > Ok, how would you like to proceed? Should I release the current (pure
>> Ruby) code with a warning regarding Vista or later? Or wait?
>> >
>> Good news is Task Sheduler 2.0 fully supports Scripting.
>> Thus an implementation using win32ole is easy.
>>
>> Here is a sample for enumerating tasks:
>>
>> #---------------------------------------------------------
>> # This sample enumerates through the tasks on the local computer and
>> # displays their name and state.
>> #---------------------------------------------------------
>> require 'win32ole'
>>
>> # Create the TaskService object.
>> service =  WIN32OLE.new("Schedule.Service")
>> service.Connect()
>>
>> # Get the task folder that contains the tasks.
>> rootFolder = service.GetFolder("\\")
>>
>> taskCollection = rootFolder.GetTasks(0)
>>
>> numberOfTasks = taskCollection.Count
>>
>> if numberOfTasks == 0
>>     puts "No tasks are registered."
>> else
>>     puts "Number of tasks registered: #{numberOfTasks}"
>>
>>     taskCollection.each do |registeredTask|
>>         puts "Task Name: #{registeredTask.Name}"
>>
>>         case registeredTask.State
>>             when "0"
>>                 taskState = "Unknown"
>>             when "1"
>>                 taskState = "Disabled"
>>             when "2"
>>                 taskState = "Queued"
>>             when "3"
>>                 taskState = "Ready"
>>             when "4"
>>                 taskState = "Running"
>>         end
>>
>>         puts "    Task State: #{taskState}"
>>     end
>>   end
>
> Ok, cool. I went ahead and released 0.2.0 without Vista support for now. Version 0.3.0 will support Vista and use win32ole behind the scenes.
>
Ok, I made taskscheduler version 2.0 and it is available at
http://121.78.227.9/win32-taskscheduler/taskscheduler2.rb

As you know, some operations need Administration right and some
operations need password.

Regards,

Park Heesob


More information about the win32utils-devel mailing list