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

Commit

Permalink
COOK-717 - Removed windows_env_vars and moved path to use env provider
Browse files Browse the repository at this point in the history
  • Loading branch information
pmorton committed Aug 23, 2011
1 parent f7c4e6b commit 86143e6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 93 deletions.
35 changes: 0 additions & 35 deletions windows/providers/env_vars.rb

This file was deleted.

39 changes: 10 additions & 29 deletions windows/providers/path.rb
Expand Up @@ -18,39 +18,20 @@
# limitations under the License.
#

action :add do
path = Registry::get_value(Windows::KeyHelper::ENV_KEY,'Path').split(";")
if !path.include?(new_resource.path)
path << new_resource.path
end

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

end

action :remove do
path = Registry::get_value(Windows::KeyHelper::ENV_KEY,'Path').split(';')
path.delete(new_resource.path)
windows_registry "RegPathRemove #{new_resource.path}" do
key_name Windows::KeyHelper::ENV_KEY
values 'Path' => path.join(';')
env "PATH" do
action :remove
delim ";"
value new_resource.path
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
29 changes: 0 additions & 29 deletions windows/resources/env_vars.rb

This file was deleted.

0 comments on commit 86143e6

Please sign in to comment.