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("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>
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.