From aaebe97e8ae75ab6f3802f086297925162cd6e5a Mon Sep 17 00:00:00 2001 From: agdula Date: Mon, 27 Apr 2015 12:09:39 +0200 Subject: [PATCH 1/2] add RDP auto login with password The fix is implementation of suggestion from @majkinetor for the closed issue https://github.com/mitchellh/vagrant/issues/4300 Works on windows 7 host. --- plugins/hosts/windows/cap/rdp.rb | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/plugins/hosts/windows/cap/rdp.rb b/plugins/hosts/windows/cap/rdp.rb index 8ddc67117..1ae9aa4d9 100644 --- a/plugins/hosts/windows/cap/rdp.rb +++ b/plugins/hosts/windows/cap/rdp.rb @@ -8,28 +8,15 @@ module VagrantPlugins module Cap class RDP def self.rdp_client(env, rdp_info) - config = nil - opts = { - "full address:s" => "#{rdp_info[:host]}:#{rdp_info[:port]}", - "prompt for credentials:i" => "1", - "username:s" => rdp_info[:username], - } - - # Create the ".rdp" file - config_path = Pathname.new(Dir.tmpdir).join( - "vagrant-rdp-#{Time.now.to_i}-#{rand(10000)}.rdp") - config_path.open("w+") do |f| - opts.each do |k, v| - f.puts("#{k}:#{v}") - end - end - + # Setup password + cmdKeyArgs = ["/add:TERMSRV/#{rdp_info[:host]}:#{rdp_info[:port]}", "/user:#{rdp_info[:username]}", "/pass:#{rdp_info[:password]}"] + Vagrant::Util::Subprocess.execute("cmdkey", *cmdKeyArgs ) + # Build up the args to mstsc - args = [config_path.to_s] + args = ["/v:#{rdp_info[:host]}:#{rdp_info[:port]}"] if rdp_info[:extra_args] args = rdp_info[:extra_args] + args end - # Launch it Vagrant::Util::Subprocess.execute("mstsc", *args) end From f035664b78485a2cf1a362c770fef1888f180b97 Mon Sep 17 00:00:00 2001 From: agdula Date: Sat, 2 May 2015 18:01:52 +0200 Subject: [PATCH 2/2] fixed cmdkey arguments The arguments contained not needed TTERMSRV/ --- plugins/hosts/windows/cap/rdp.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/hosts/windows/cap/rdp.rb b/plugins/hosts/windows/cap/rdp.rb index 1ae9aa4d9..aec802168 100644 --- a/plugins/hosts/windows/cap/rdp.rb +++ b/plugins/hosts/windows/cap/rdp.rb @@ -9,7 +9,7 @@ module VagrantPlugins class RDP def self.rdp_client(env, rdp_info) # Setup password - cmdKeyArgs = ["/add:TERMSRV/#{rdp_info[:host]}:#{rdp_info[:port]}", "/user:#{rdp_info[:username]}", "/pass:#{rdp_info[:password]}"] + cmdKeyArgs = ["/add:#{rdp_info[:host]}:#{rdp_info[:port]}", "/user:#{rdp_info[:username]}", "/pass:#{rdp_info[:password]}"] Vagrant::Util::Subprocess.execute("cmdkey", *cmdKeyArgs ) # Build up the args to mstsc