52

Is it possible to have a URL that launches a remote desktop session? I realize it may be considered a security vulnerability for some, but the convenience would really save me a lot of time.

I would like to have a hyperlink like: remotedesktop://example.org where clicking on it launches mstsc.exe with the target computer filled in (in this case with example.org).

How best to set this up?

12 Answers 12

24

You could use a custom URL protocol handler, but this would mean the URLs only worked on computers where you had set this up. I think you'd also need a program to handle taking the URL as remotedesktop://example.org and converting to /v:example.org - although a batch file could probably do this.

See http://msdn.microsoft.com/en-us/library/aa767914(v=vs.85).aspx for more information.

3
  • 2
    Something like rdp://example.org Jul 23, 2015 at 16:40
  • 2
    This answer is obsolete. LJT's one is up to date, with documentation for the new rdp:// URI scheme.
    – Lloeki
    Sep 21, 2016 at 9:04
  • The link in this answer is broken.
    – Cullub
    Jul 30, 2020 at 20:53
10

Original post 2016

For Windows 8.1, Windows Server 2012 R2 there is now the Remote Desktop Client URI Scheme Support

Example: rdp://full%20address=s:mypc:3389&audiomode=i:2&disable%20themes=i:1

See here for the details, including the full list of query string parameters.

Edit - updated info April 2023

Microsoft have released a remote desktop client that is available from Microsoft store - https://learn.microsoft.com/en-us/windows-server/remote/remote-desktop-services/clients/remote-desktop-clients which allows you to configure hosts you want to connect inside the client, to which you can create shortcuts to in the Start menu in Win11, which will allow you to launch via a click. However as per https://superuser.com/a/1594776/386189 there doesn't appear to be a cmdline you can use, the start menu shortcuts are stored in a binary format inside %LocalAppData%\Packages\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy\LocalState

However this version in the Microsoft Store isn't activately updated any more, as it's superceded by Azure Virtual Desktop clients, see https://learn.microsoft.com/en-us/azure/virtual-desktop/users/connect-windows?tabs=subscribe for detail on that if you are using Azure.

4
  • 9
    This does not work on my Win10 Pro -- did it ever actually work?
    – dualed
    Sep 29, 2016 at 12:40
  • 2
    I second that. I've tried multiple combinations and browers. I even put it into Start->Run, but nothing seems to recognize that URL syntax. I don't think they ever completed support for it.
    – penguin359
    Jan 17, 2018 at 2:02
  • 5
    This syntax doesn't apply to Windows. It is only available on Mac, iOS, and Android. The Windows RDP client (mstsc.exe) doesn't support any URL command line argument. You have to use something like the JScript solution linked in xorsyst's answer.
    – Ian Boyd
    May 3, 2018 at 19:25
  • Per previous comment the answer above describes the Legacy rdp URI Scheme that is deprecated for Windows clients but still works for Mac, iOS, and Android.
    – Blindspots
    Mar 28, 2023 at 15:42
7

There is currently no official way

Well, Microsoft SAYS they have two URI schemes for this in Server 2012 R2: ms-rd:// and rdp://

But as of now, 2020-10-16, these do NOT work on my Win10 machine. (Exact version: ver.exe outputs: Microsoft Windows [Version 10.0.19041.572])

So if I run inside cmd.exe either of these:

C:\>start ms-rd://example.com

or

C:\>start rdp://example.com

then nothing good happens. I just get the generic "Pick an app" dialog. (C:\Windows\System32\OpenWith.exe)

And I double checked with URLProtocolView (https://www.nirsoft.net/utils/url_protocol_view.html) and: No. Neither scheme is registered with a handler on my system.

Also these schemes are NOT in the official IANA URI Scheme list (https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml)

So the answer seems to be: Nope. There is no URI scheme for RDP that you can expect to "just work" on a modern PC. You can MANUALLY make it work, by just manually adding a scheme and a handler. (See other answers.) But that's not the same.

Sources: Microsoft talking about their URI schemes here:

6

I originally said no, but if you have XP, there is something called the Remote Desktop Web Connection. I initially forgot there was a version for XP.

http://www.microsoft.com/download/en/details.aspx?DisplayLang=en&id=18145

http://support.microsoft.com/kb/284931

3
  • There was something similar for Small Business Server 2003 called Remote Web Workplace, but even then, you could not use a direct URL. en.wikipedia.org/wiki/Microsoft_Remote_Web_Workplace
    – KCotreau
    Jul 18, 2011 at 17:10
  • Correct me if I'm wrong- this requires me to install/configure something on each server that I would like to connect to? That's going to be prohibitive for me. Thanks though!
    – optus
    Jul 18, 2011 at 17:47
  • Yes that would be correct. And I agree, it is a pain in the neck...but you asked. :) Support for this was dropped as of Vista.
    – KCotreau
    Jul 18, 2011 at 23:08
4

Save the following text as C:\Windows\RDP.js:

var destination=(WScript.Arguments(0))
var search='rdp://'
var rdpexe='C:\\WINDOWS\\system32\\mstsc.exe'
//WScript.Echo(destination)
destination=destination.replace(search, '')
destination=destination.replace('/', '')
var ws = new ActiveXObject("WScript.Shell")
//WScript.Echo(rdpexe + " /v:" + destination)
ws.Exec(rdpexe + " /v:" + destination)

Save the next piece as RDP.reg:

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\rdp]
@="URL:Remote Desktop Connection"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\rdp\DefaultIcon]
@="C:\\WINDOWS\\System32\\mstsc.exe"
[HKEY_CLASSES_ROOT\rdp\shell]
[HKEY_CLASSES_ROOT\rdp\shell\open]
[HKEY_CLASSES_ROOT\rdp\shell\open\command]
@="wscript.exe C:\\WINDOWS\\rdp.js %1"

Double click and woalya! When you click something like rdp://192.168.0.1 you will be connected to that server by RDP.

3

I think this would work, and might be the effect you are looking for:

With your local copy of Remote Desktop, set up a connection to the target host. But don't connect; instead, save the connection as an RDP file.

Place that file on your web server. Serve the file with a standard <A HREF='path.to.your/file.rdp'> link. (Note: you may need to update your web server config to "download" this file rather than "serve" it to the web browser.)

The user will probably need to know to run the downloaded file... but it should get their computer to launch RD and initiate a connection to the target host.

2

This might be useful to someone, but here's an Open Source .NET exe that registers the URL handling off to mstsc: https://github.com/richard-green/MstscLauncher

After running that, it will allow you to click links like this: mstsc://your-server/?w=1024&h=768

1

It's not quite what you want, but with Windows Server 2008/R2, you can have your RemoteApps and RDP machines shown on a TS/RD Web Access webpage.

In conjunction with TS/RD Gateway, you could have RDP working through port 443, which is useful in places that block other ports.

TS Web Access

1
  • I sense that he means directly to his computer, like to a home computer. I could be wrong though.
    – KCotreau
    Jul 18, 2011 at 17:20
1

I have a way to fix this with one simple reg file

just add this to HKU and your system will handle RDP links formatted as rdp://

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Classes\rdp]
@="URL:rdp Protocol"
"URL Protocol"="rdp://"
[HKEY_CURRENT_USER\Software\Classes\rdp\shell]
[HKEY_CURRENT_USER\Software\Classes\rdp\shell\open]
[HKEY_CURRENT_USER\Software\Classes\rdp\shell\open\command]
@="cmd /V:ON /c set params=%1 && set params=!params:rdp://=! && start mstsc /v:\"!params:/=!\""

This is a modification of this solution- so I cant take full credit. Make ssh:// links open with PuTTY

0

Simply run the following *.bat file (original file from the no longer available RDP Hyperlink article) and use <a href="rdp://someserver">rdp://someserver</a>.

Beware though that some AVs will classify the behavior as the RCE it is aka Lockdown exploit

@echo off
:http://www.jjclements.co.uk/2010/02/21/rdp-hyperlink/
:menu
echo RDP:// HyperLink - James Clements - [email protected]
echo ----------------------------------------------------------
echo.
echo.
echo 1. Install RDP Association
echo 2. Uninstall RDP Association
echo 3. Quit
echo.
set choice=
set /p choice=[1,2,3]? 
echo.
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='1' goto install
if '%choice%'=='2' goto uninstall
if '%choice%'=='3' goto quit
echo.
echo.
echo "%choice%" is not a valid option - please try again
echo.
pause
cls
goto MENU

:quit
cls
exit

:uninstall
if not exist "C:\Windows\hyperlink-rdp.js" (
cls
echo RDP:// HyperLink - James Clements - [email protected]
echo ----------------------------------------------------------
echo.
echo.
echo RDP:// HyperLink not installed - nothing to remove
echo.
pause
exit)

del "C:\Windows\hyperlink-rdp.js" /f
reg delete "HKCR\rdp" /f

cls
echo RDP:// HyperLink - James Clements - [email protected]
echo ----------------------------------------------------------
echo.
echo.
echo RDP:// HyperLink uninstalled successfully
echo.
pause
exit

:install
if exist "C:\Windows\hyperlink-rdp.js" (
cls
echo RDP:// HyperLink - James Clements - [email protected]
echo ----------------------------------------------------------
echo.
echo.
echo RDP:// HyperLink already installed - nothing to install
echo.
pause
exit)

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

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"

cls
echo RDP:// HyperLink - James Clements - [email protected]
echo ----------------------------------------------------------
echo.
echo.
echo RDP:// HyperLink installed successfully
echo.
pause
exit
1
  • Avoid posting answers to old questions that already have well received answers unless you have something substantial and new to add.
    – Toto
    Nov 7, 2022 at 15:02
0

As others suggested and I discovered (as a basic PowerShell, markdown user), the hyperlink doesn't work. Embedded mstsc.exe or start command doesn't work, apparently for security reasons. Changing registry key is unbearable. A modern (now y2023) way of doing this, is to write to a .rdp file and let the system to open it with default tool (say mstsc).

This JavaScript was the solution worked for me. Modern browsers natively support JavaScript, so a single html file plus another single js file work perfectly.

Within hours, I also created a simpler version with removal of some parameters. Mark my first JScript coding and post at StackExchange.

Credit and thanks to the original author: https://github.com/wel97459/RDPgen-JS

How I did it exactly: Starting with JScript function and save it as RDPgen.js

        function generatorRDP(targetID, address)
    {
        var fdata = "";
        fdata += "full address:s:"+ address + "\n"
        fdata += "username:s:"+ "domain\\username";
        var btn = document.getElementById(targetID);
        btn.href = "data: text/plain;charset=utf-8," + encodeURIComponent(fdata);
        btn.download = "temp.rdp";
    }

Then I actually worked the markdown

<script src="RDPgen.js"></script>

| host | IP  | Connect |
| :--- | :-- | :------ |
| host1| 1.0.0.1| <button><a id="rdp1">rdp</a><script>generatorRDP("rdp1","1.0.0.1")</script></button> |
| host2| 1.0.0.2| <button><a id="rdp2">rdp</a><script>generatorRDP("rdp1","1.0.0.2")</script></button> |

I used MarkdownAllInOne VSCode extension to print the html file. If you can directly work on htlm, by all means. This is part of the htlm result from markdown and extension.

<tbody>
<tr>
<td style="text-align:left">host1</td>
<td style="text-align:left">1.0.0.1</td>
<td style="text-align:left"><button><a id="rdp1">rdp</a><script>generatorRDP(&quot;rdp1&quot;,&quot;1.0.0.1&quot;)</script></button></td>
</tr>
<tr>
<td style="text-align:left">host2</td>
<td style="text-align:left">1.0.0.2</td>
<td style="text-align:left"><button><a id="rdp2">rdp</a><script>generatorRDP(&quot;rdp1&quot;,&quot;1.0.0.2&quot;)</script></button></td>
</tr>
</tbody>

So the " will need to be replaced by quote " Then it's like this:

<!DOCTYPE html>
    <html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <style>
/* From extension vscode.github */
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

.vscode-dark img[src$=\#gh-light-mode-only],
.vscode-light img[src$=\#gh-dark-mode-only] {
    display: none;
}

</style>
        
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Microsoft/vscode/extensions/markdown-language-features/media/markdown.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Microsoft/vscode/extensions/markdown-language-features/media/highlight.css">
<style>
            body {
                font-family: -apple-system, BlinkMacSystemFont, 'Segoe WPC', 'Segoe UI', system-ui, 'Ubuntu', 'Droid Sans', sans-serif;
                font-size: 14px;
                line-height: 1.6;
            }
        </style>
        <style>
.task-list-item {
    list-style-type: none;
}

.task-list-item-checkbox {
    margin-left: -20px;
    vertical-align: middle;
    pointer-events: none;
}
</style>
        
    </head>
    <body class="vscode-body vscode-light">
        <script src="RDPgen.js"></script>
<table>
<thead>
<tr>
<th style="text-align:left">host</th>
<th style="text-align:left">IP</th>
<th style="text-align:left">Connect</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">host1</td>
<td style="text-align:left">1.0.0.1</td>
<td style="text-align:left"><button><a id="rdp1">rdp</a><script>generatorRDP("rdp1","1.0.0.1")</script></button></td>
</tr>
<tr>
<td style="text-align:left">host2</td>
<td style="text-align:left">1.0.0.2</td>
<td style="text-align:left"><button><a id="rdp2">rdp</a><script>generatorRDP("rdp1","1.0.0.2")</script></button></td>
</tr>
</tbody>
</table>

        
        
    </body>
    </html>

Place the html file and RDPgen.js at the same place and the invoke rdp feature works by downloading a new .rdp file and opening it.

1
  • Understood. I have put the code and detailed steps. May still need refine the JScript and html code further. I am just not a good coder :)
    – yunpeng d
    Mar 29, 2023 at 3:26
-2

Old topic, but Chrome has a remote desktop plugin to do that.

You also have HTML5 based solutions like Guacamole for Linux or Myrtille for Windows.

4
  • Can you clarify what remote desktop plugin you're referring to?
    – caesay
    Nov 28, 2017 at 1:25
  • 1
    That extension is not related to windows RDP whatsoever. It is a completely different protocol requiring you to have this extension configured on both devices. Not sure how this actually answers the question of "How to launch remote desktop from URL". It's also not clear if it would be possible to launch "Chrome Remote Desktop" with a URL either
    – caesay
    Nov 30, 2017 at 7:18
  • The OP was speaking about mstsc.exe, so RDP indeed; but RDP is just one form of remote desktop; a generic remotedesktop:// link could apply to any remote desktop implementation. An rdp:// link launching mstsc.exe is possible following this solution. There is also the Microsoft remote desktop web access solution. Regarding the chrome remote desktop, it's accessible through the url chrome://apps within chrome.
    – cedrozor
    Dec 1, 2017 at 14:53

You must log in to answer this question.

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