6

Is there a way to create a hyperlink that will invoke a Remote Desktop connection to a Windows Machine?

5 Answers 5

7

Not as such. You could save an RDP file on your server and offer a link to that, so long as your MIME types are correctly set-up on the server it should download and then when opened by the user, should open RDP with the right settings.

Your not going to be able to just run an executable (in this case mstsc.exe) straight from the browser, that would be a pretty big security hole, the user will need to download something and consciously open it.

7

As Sam mentioned, just store a RDP file on your server or write something that will generate the RDP file for you.

The MIME type you need to send is "application/x-rdp".

I am not sure exactly what you are needing. Another option may be too use a java applet RDP client. For examople (http://properjavardp.sourceforge.net/)

2

Here is an updated version that does not require a wscript file, you only need the registry keys instead, based on PowerShell.

reg add "HKCR\rdp" /f /v "" /t REG_SZ /d "URL:Remote Desktop Connection"
reg add "HKCR\rdp" /f /v "URL Protocol" /t REG_SZ /d ""
reg add "HKCR\rdp\DefaultIcon" /f /v "" /t REG_SZ /d "C:\WINDOWS\System32\mstsc.exe"
REM do the next 1 of the other, but not both
reg add "HKCR\rdp\shell\open\command" /f /v "" /t REG_SZ /d "powershell.exe $URL = '%1%'; $SERVER = $url.replace('rdp://',''); $SERVER = $SERVER.replace('/',''); mstsc.exe /v $SERVER"
REM OR
reg add "HKCR\rdp\shell\open\command" /f /v "" /t REG_SZ /d "powershell.exe $URL = '%1%'; $SERVER = $url.replace('rdp://',''); $SERVER = $SERVER.replace('/',''); mstsc.exe /v $SERVER /restrictedAdmin"
1

I found this useful post by James Clements, which describes a technique which seems to work: http://www.jjclements.co.uk/2010/02/21/rdp-hyperlink/ This requires each individual who's going to click the rdp:// hyperlinks to run a batch file setting up their system appropriately. If that meets your needs, then read on.

James provides a small .BAT file which sets up the rdp:// association, so that after installing the association you can click hyperlinks to rdp://myserver or rdp://myserver.myhost.com and it'll launch MSTSC.exe connecting to the specified server. (Stack Overflow won't let me insert those hyperlinks into this post, which is fair enough, but if you control the HTML you can do it.)

The central part of the batch file creates two things:

1) A Javascript file in a known location (C:\Windows\hyperlink-rdp.js) with the following content:

var server=(WScript.Arguments(0))
var prefix='rdp://'
var app='C:\\WINDOWS\\system32\\mstsc.exe'
server=server.replace(prefix, '')
server=server.replace('/', '')
var shell = new ActiveXObject("WScript.Shell")
shell.Exec(app + " /v:" + server)

2) A few registry settings to associate rdp:// links with that script. These are supplied in the form of commands that can be run from the Windows command prompt:

reg add "HKCR\rdp" /f /v "" /t REG_SZ /d "URL:Remote Desktop Connection"
reg add "HKCR\rdp" /f /v "URL Protocol" /t REG_SZ /d ""
reg add "HKCR\rdp\DefaultIcon" /f /v "" /t REG_SZ /d "C:\WINDOWS\System32\mstsc.exe"
reg add "HKCR\rdp\shell\open\command" /f /v "" /t REG_SZ /d "wscript.exe C:\WINDOWS\hyperlink-rdp.js %%1"

You can download and run rdp.bat from James Clements' website (and distribute it to other users), or you can just save that hyperlink-rdp.js file yourself and add those registry keys yourself. One could also create a .reg file containing the same settings. James's batch file also provides a way to uninstall the association if you want.

0

There is a workaround if you only need it for personal use. You could create custom protocol handle and use it through your HTML. Here is a good example.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .