From 746b568176d07c84d878d840a3c221bc850e64fa Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 12 Apr 2014 15:44:39 -0700 Subject: [PATCH] hosts/windows: rdp_client cap --- plugins/hosts/windows/cap/rdp.rb | 36 ++++++++++++++++++++++++++++++++ plugins/hosts/windows/plugin.rb | 5 +++++ 2 files changed, 41 insertions(+) create mode 100644 plugins/hosts/windows/cap/rdp.rb diff --git a/plugins/hosts/windows/cap/rdp.rb b/plugins/hosts/windows/cap/rdp.rb new file mode 100644 index 000000000..f5bbce8bb --- /dev/null +++ b/plugins/hosts/windows/cap/rdp.rb @@ -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 diff --git a/plugins/hosts/windows/plugin.rb b/plugins/hosts/windows/plugin.rb index 45ad11467..fe3b28923 100644 --- a/plugins/hosts/windows/plugin.rb +++ b/plugins/hosts/windows/plugin.rb @@ -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