Merge pull request #5670 from agdula/master
add RDP auto login with password
This commit is contained in:
commit
01369342db
|
@ -8,28 +8,15 @@ module VagrantPlugins
|
||||||
module Cap
|
module Cap
|
||||||
class RDP
|
class RDP
|
||||||
def self.rdp_client(env, rdp_info)
|
def self.rdp_client(env, rdp_info)
|
||||||
config = nil
|
# Setup password
|
||||||
opts = {
|
cmdKeyArgs = ["/add:#{rdp_info[:host]}:#{rdp_info[:port]}", "/user:#{rdp_info[:username]}", "/pass:#{rdp_info[:password]}"]
|
||||||
"full address:s" => "#{rdp_info[:host]}:#{rdp_info[:port]}",
|
Vagrant::Util::Subprocess.execute("cmdkey", *cmdKeyArgs )
|
||||||
"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
|
|
||||||
|
|
||||||
# Build up the args to mstsc
|
# Build up the args to mstsc
|
||||||
args = [config_path.to_s]
|
args = ["/v:#{rdp_info[:host]}:#{rdp_info[:port]}"]
|
||||||
if rdp_info[:extra_args]
|
if rdp_info[:extra_args]
|
||||||
args = rdp_info[:extra_args] + args
|
args = rdp_info[:extra_args] + args
|
||||||
end
|
end
|
||||||
|
|
||||||
# Launch it
|
# Launch it
|
||||||
Vagrant::Util::Subprocess.execute("mstsc", *args)
|
Vagrant::Util::Subprocess.execute("mstsc", *args)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue