hosts/windows: rdp_client cap

This commit is contained in:
Mitchell Hashimoto 2014-04-12 15:44:39 -07:00
parent de7b4bbdc1
commit 746b568176
2 changed files with 41 additions and 0 deletions

View File

@ -0,0 +1,36 @@
require "tempfile"
require "vagrant/util/powershell"
module VagrantPlugins
module HostWindows
module Cap
class RDP
def self.rdp_client(env, rdp_info)
config = nil
opts = {
"drivestoredirect:s" => "*",
"full address:s" => rdp_info[:host],
"prompt for credentials:i" => "1",
"username:s" => rdp_info[:username],
}
# Create the ".rdp" file
config = Tempfile.new(["vagrant-rdp", ".rdp"])
opts.each do |k, v|
config.puts("#{k}:#{v}")
end
config.close
# Launch it
Vagrant::Util::PowerShell.execute("mstsc", config.path)
ensure
if config
config.close
config.unlink
end
end
end
end
end
end

View File

@ -15,6 +15,11 @@ module VagrantPlugins
require_relative "cap/nfs"
Cap::NFS
end
host_capability("windows", "rdp_client") do
require_relative "cap/rdp"
Cap::RDP
end
end
end
end