diff --git a/lib/vagrant-hostmanager/hosts_file.rb b/lib/vagrant-hostmanager/hosts_file.rb index 582ba53..7c4ac8f 100644 --- a/lib/vagrant-hostmanager/hosts_file.rb +++ b/lib/vagrant-hostmanager/hosts_file.rb @@ -10,7 +10,11 @@ module VagrantPlugins realhostfile = '/etc/inet/hosts' move_cmd = 'mv' elsif (machine.communicate.test("test -d $Env:SystemRoot")) - realhostfile = "#{ENV['WINDIR']}\\System32\\drivers\\etc\\hosts" + windir = "" + machine.communicate.execute("echo %SYSTEMROOT%", {:shell => :cmd}) do |type, contents| + windir << contents.gsub("\r\n", '') if type == :stdout + end + realhostfile = "#{windir}\\System32\\drivers\\etc\\hosts" move_cmd = 'mv -force' else realhostfile = '/etc/hosts'