Remote Desktop from Excel.

nirvana_

Board Regular
Joined
Mar 25, 2009
Messages
141
Hello,

Here is my situation. I have a excel sheet with Server names in Column A and Passwords in Column B. I want to be able to highlight a server name in Column A and run a shortcut key e.g. Ctrl + K to launch a RDP session automatically.

The RDP session should read the active cell's Server name and the corresponding password and connect. Is this possible?

I have added references to Microsoft Terminal Services ActiveX Client Library to do this, but it doesnt work. When I run the Macro I nothing shows up. Has anyone done something similar? Here is how far I have progresssed.

Code:
Sub ConnectToTSC()
    Dim Tsc As MSTSCLib.IMsRdpClient2
    Set Tsc = New MSTSCLib.MsRdpClient2
    Tsc.Server = ActiveCell.Value
    Tsc.UserName = "myUsername"
    Tsc.AdvancedSettings2.ClearTextPassword = ActiveCell.Offset(0, 1).Value
    Tsc.Domain = "myDomain"
    Tsc.SecuredSettings2.StartProgram = _
          "C:\Program Files\Microsoft office\OFFICE11\EXCEL.EXE"
    Tsc.Connect
End Sub

Any pointers in the right direction will help?

Thanks.
 

Some videos you may like

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

westconn1

Board Regular
Joined
Feb 20, 2009
Messages
245
an alternative is to write the rdp configuration file for the connections, then shellexecute it
this i have done with success
 

nirvana_

Board Regular
Joined
Mar 25, 2009
Messages
141
Hello westconn1,

Thanks for your response. I just need one more doubt clarified.

I can write the rdp file at runtime without any problem, but I was wondering how I can supply the password to be stored in the file? As you may be aware the password is hashed and is not stored as clear text. Also I dont see any switches with mstsc.exe to specify a password to login automatically.

Are you using cryptrdp5 to generate the hash to use as password in the rdp file OR do you use sendkeys to type in the password during runtime?

Thanks again.
 

westconn1

Board Regular
Joined
Feb 20, 2009
Messages
245
mostly i only edit the previous file so the password remains from previous
reason for editing is dynamic ip, so really i only change the ip and port
had not thought about that when i posted before
 

nirvana_

Board Regular
Joined
Mar 25, 2009
Messages
141
Thanks for your response. I think I have it sorted now. I wasnt able to use mstsc.exe the default rdp client. But there is another version available on the internet which allows for passwords to be passed for rdp connections. You can read about it on the website given below.

http://abaronov.blogspot.com/2007/02/rdp-auto-logon-20-beta-1.html

With autordp I can actually logon with servername, username and password which certainly helps.

There seems to be another option to use cryptrdp5 to generate the password at runtime to store in the rdp connection file. I havent tried this, but I will sometime.

Ideally I would have listed to use MsTscAx or MsRdpClient2 to get connected because its the default in windows.

As of now I have a temporary solution, but I will think of something to get this to work.

Thanks again.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,499
Messages
5,596,517
Members
414,074
Latest member
Matthew Kakde

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top