Reputation: 23
I want to connect a remote computer by using RDP (mstsc.exe) from Excel (VBA macro). I am using the following code for this.
Code:
Sub Connect()
RDPWindow = Shell("C:\windows\system32\mstsc.exe /admin /v:" & "ServerName", 1)
End Sub
but I don't want to enter my credentials manually. How can I add that thing in my code so that I can directly connect any remote machine by using specific credentials?
Upvotes: 2
Views: 8621
Reputation: 175748
Place the credentials in the credentials store keyed to the remote address/name by using shell
to execute:
cmdkey /generic:TERMSRV/10.1.2.3 /user:UUUU /pass:XXXX
Run TS with:
mstsc /v:10.1.2.3
To remove when you are done:
cmdkey /delete:TERMSRV/10.1.2.3
Upvotes: 3
Reputation: 10239
Passing the username and password in not possbile, because there is no parameter for this.
But Mstsc supports connection files
Upvotes: 0