Skip to content
This repository has been archived by the owner on Nov 23, 2017. It is now read-only.

Commit

Permalink
Fix COOK-710 and COOK-711
Browse files Browse the repository at this point in the history
  • Loading branch information
pmorton committed Aug 19, 2011
1 parent 9eae58f commit f7c4e6b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
6 changes: 4 additions & 2 deletions windows/providers/auto_run.rb
Expand Up @@ -19,13 +19,15 @@
#

action :create do
windows_registry 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run' do
windows_registry "CreateAutoRun #{new_resource.program} #{new_resource.args}" do
key_name 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run'
values new_resource.name => "\"#{new_resource.program}\" #{new_resource.args}"
end
end

action :remove do
windows_registry 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run' do
windows_registry "RemoveAutoRun #{new_resource.program} #{new_resource.args}" do
key_name 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run'
values new_resource.name => ''
action :remove
end
Expand Down
6 changes: 4 additions & 2 deletions windows/providers/env_vars.rb
Expand Up @@ -19,14 +19,16 @@
#

action :create do
windows_registry Windows::KeyHelper::ENV_KEY do
windows_registry "CreateEnv #{new_resource.name} #{new_resource.value}" do
key_name Windows::KeyHelper::ENV_KEY
values new_resource.name => new_resource.value
action :create
end
end

action :remove do
windows_registry Windows::KeyHelper::ENV_KEY do
windows_registry "RemoveEnv #{new_resource.name} #{new_resource.value}" do
key_name Windows::KeyHelper::ENV_KEY
values new_resource.name => ''
action :remove
end
Expand Down
12 changes: 7 additions & 5 deletions windows/providers/path.rb
Expand Up @@ -19,21 +19,23 @@
#

action :add do
path = ENV['PATH'].split(';')
path = Registry::get_value(Windows::KeyHelper::ENV_KEY,'Path').split(";")
if !path.include?(new_resource.path)
path.insert(-1,new_resource.path)
path << new_resource.path
end

windows_registry Windows::KeyHelper::ENV_KEY do
windows_registry "RegPathAdd #{new_resource.path}" do
key_name Windows::KeyHelper::ENV_KEY
values 'Path' => path.join(';')
end
timeoutVars
end

action :remove do
path = ENV['PATH'].split(';')
path = Registry::get_value(Windows::KeyHelper::ENV_KEY,'Path').split(';')
path.delete(new_resource.path)
windows_registry Windows::KeyHelper::ENV_KEY do
windows_registry "RegPathRemove #{new_resource.path}" do
key_name Windows::KeyHelper::ENV_KEY
values 'Path' => path.join(';')
end
timeoutVars
Expand Down
6 changes: 3 additions & 3 deletions windows/resources/registry.rb
Expand Up @@ -22,11 +22,11 @@

actions :create, :modify, :force_modify, :remove

attribute :key_name, :kind_of => String, :name_attribute => true
attribute :values, :kind_of => Hash
attribute :name, :kind_of => String, :name_attribute => true
attribute :key_name, :kind_of => String, :required => true
attribute :values, :kind_of => Hash, :required => true

def initialize(name, run_context=nil)
super
@action = :modify
@key_name = name
end

0 comments on commit f7c4e6b

Please sign in to comment.