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

COOK-710, COOK-711 Refactor of registry provider #184

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions windows/providers/auto_run.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@
# #


action :create do 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}" values new_resource.name => "\"#{new_resource.program}\" #{new_resource.args}"
end end
end end


action :remove do 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 => '' values new_resource.name => ''
action :remove action :remove
end end
Expand Down
33 changes: 0 additions & 33 deletions windows/providers/env_vars.rb

This file was deleted.

37 changes: 10 additions & 27 deletions windows/providers/path.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -18,37 +18,20 @@
# limitations under the License. # limitations under the License.
# #


action :add do
path = ENV['PATH'].split(';')
if !path.include?(new_resource.path)
path.insert(-1,new_resource.path)
end


windows_registry Windows::KeyHelper::ENV_KEY do action :add do
values 'Path' => path.join(';') env "PATH" do
action :create
delim ";"
value new_resource.path
end end
timeoutVars
end end


action :remove do action :remove do
path = ENV['PATH'].split(';') env "PATH" do
path.delete(new_resource.path) action :delete
windows_registry Windows::KeyHelper::ENV_KEY do delim ";"
values 'Path' => path.join(';') value new_resource.path
end end
timeoutVars
end

private
# Notify all processes that the environmental variables have been updated.
def timeoutVars
# Dosent seem to work... You may need to re-login
Chef::Log.debug("Telling other processes that the env vars have been updated")
require 'Win32API'
sendMessageTimeout = Win32API.new('user32', 'SendMessageTimeout', 'LLLPLLP', 'L')
hwnd_broadcast = 0xffff
wm_settingchange = 0x001A
smto_abortifhung = 2
result = 0
sendMessageTimeout.call(hwnd_broadcast, wm_settingchange, 0, 'Environment', smto_abortifhung, 5000, result)
end end
Empty file added windows/providers/shortcut.rb
Empty file.
29 changes: 0 additions & 29 deletions windows/resources/env_vars.rb

This file was deleted.

6 changes: 3 additions & 3 deletions windows/resources/registry.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@


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


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


def initialize(name, run_context=nil) def initialize(name, run_context=nil)
super super
@action = :modify @action = :modify
@key_name = name
end end
Empty file added windows/resources/shortcut.rb
Empty file.