summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--providers/task.rb6
-rw-r--r--resources/task.rb1
2 files changed, 5 insertions, 2 deletions
diff --git a/providers/task.rb b/providers/task.rb
index ab6b9ae..fbe8bd2 100644
--- a/providers/task.rb
+++ b/providers/task.rb
@@ -25,7 +25,8 @@ action :create do
if @current_resource.exists
Chef::Log.info "#{@new_resource} task already exists - nothing to do"
else
- cmd = "schtasks /Create /TN \"#{@new_resource.name}\" "
+ use_force = @new_resource.force ? '/F' : ''
+ cmd = "schtasks /Create #{use_force} /TN \"#{@new_resource.name}\" "
cmd += "/SC #{@new_resource.frequency} "
cmd += "/MO #{@new_resource.frequency_modifier} " if [:minute, :hourly, :daily, :weekly, :monthly].include?(@new_resource.frequency)
cmd += "/TR \"#{@new_resource.command}\" "
@@ -75,7 +76,8 @@ end
action :delete do
if @current_resource.exists
- cmd = "schtasks /Delete /TN \"#{@current_resource.name}\""
+ use_force = @new_resource.force ? '/F' : ''
+ cmd = "schtasks /Delete #{use_force} /TN \"#{@current_resource.name}\""
shell_out!(cmd, {:returns => [0]})
@new_resource.updated_by_last_action true
Chef::Log.info "#{@new_resource} task deleted"
diff --git a/resources/task.rb b/resources/task.rb
index 26af891..3a696f5 100644
--- a/resources/task.rb
+++ b/resources/task.rb
@@ -28,6 +28,7 @@ attribute :cwd, :kind_of => String
attribute :user, :kind_of => String, :default => nil
attribute :password, :kind_of => String, :default => nil
attribute :run_level, :equal_to => [:highest, :limited], :default => :limited
+attribute :force, :kind_of => [ TrueClass, FalseClass ], :default => false
attribute :frequency_modifier, :kind_of => Integer, :default => 1
attribute :frequency, :equal_to => [:minute,
:hourly,