Enabling hyperlinks for remote connections in Windows

by Ed Fisher on 2009-11-23

in Whatever

updated 20091204

lightbulb I was getting ready for a presentation that will combine a pptx deck with live demo, and I wanted to embed a hyperlink to launch the terminal services client so I could just click right from the slide. Apparently, this was not as obvious as I hoped it would be, but I my Google-fu was strong enough to let me find a dozen ways NOT to do this, and one post by the Electronic Samurai that showed me the way. He created the js and registry keys for rdp and vnc. Considering the number of times I use PuTTY to make an ssh connection to a box, I am going to include that below. And telnet, while old and busted, is still out there so I am including it too.

Most of these methods combine a small bit of javascript with shell entries added to the registry. All will need a reg hack. While you do not have to run in compatibility or as an administrator to make these work, you will of course have to have admin rights to alter the registry, and in Windows 7 or Vista, to copy the js files to c:\windows. I tested this on Windows 7 Ultimate 32-bit. In the following examples, we will assume that you have Windows installed in c:\windows, that you copied the putty.exe to the Windows directory, and that you will grab the vncviewer below. With a little work, you should be able to adapt these to fit your environment and choice of binary.

RDP

Here is how you can enable Windows to recognise rdp:// hyperlinks, and open them using the MSTSC client. Copy the text below into a text file, and save it as c:\windows\rdp.js. The easiest way to do this with UAC in place is to open an administrative command prompt, and from that enter
notepad c:\windows\rdp.js [enter]

    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)

Then, copy the text below into another text file, saving it anywhere (like your Desktop) 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"

Import that into your registry by double-clicking it, accept the UAC prompt, and you’re done. Now, any hyperlink in the format rdp://ip.addr or rdp://fqdn that Windows encounters will launch the mstsc.exe /v:ip.addr or mstsc.exe /v:fqdn. You can edit the js to add other switches as you wish, otherwise it will process with the default settings in your default.rdp file.

SSH

You can do the same thing for secure shell hyperlinks using ssh://. Here are the contents you will need to save to c:\windows\ssh.js, just like you did above for rdp.

    var destination=(WScript.Arguments(0))
    var search=’ssh://’
    var sshexe=’C:\\WINDOWS\\putty.exe’
    //WScript.Echo(destination)
    destination=destination.replace(search, ”)
    destination=destination.replace(‘/’, ”)
    var ws = new ActiveXObject("WScript.Shell")
    //WScript.Echo(sshexe + " " + destination)
    ws.Exec(sshexe + " " +  destination)

And now, here are the contents of the file to create the registry key entries for the ssh:// hyperlink. Do the same thing you did for RDP.

    Windows Registry Editor Version 5.00
    [HKEY_CLASSES_ROOT\ssh]
    @="URL:Secure Shett Connection"
    "URL Protocol"=""
    [HKEY_CLASSES_ROOT\ssh\DefaultIcon]
    @="C:\\WINDOWS\\putty.exe"
    [HKEY_CLASSES_ROOT\ssh\shell]
    [HKEY_CLASSES_ROOT\ssh\shell\open]
    [HKEY_CLASSES_ROOT\ssh\shell\open\command]
    @="wscript.exe C:\\WINDOWS\\ssh.js %1"

The same caveat applies, save that putty at the command line doesn’t really offer many switches, to ssh://fqdn will execute c:\windows\putty.exe fqdn. Adjust as needed if you saved putty.exe to another location.

VNC

Next, you can do the same thing for VNC hyperlinks using VNC://. I downloaded the realvncviewer from here and saved it as c:\program files\vnc\vncviewer.exe. Here are the contents you will need to save to c:\windows\vnc.js, just like you did above for rdp and ssh. In the below example, the vnc viewer is stored at c:\program files\vnc\vncviewer.exe.

    var destination=(WScript.Arguments(0))
    var search=’vnc://’
    //Modify the path to VNC Viewer!
    var vncexe=’c:\\progra~1\\VNC\\vncviewer.exe’
    //WScript.Echo(destination)
    destination=destination.replace(search, ”)
    destination=destination.replace(‘/’, ”)
    var ws = new ActiveXObject("WScript.Shell")
    //WScript.Echo(vncexe + " " + destination)
    ws.Exec(vncexe + " " + destination)

And now, here are the contents of the file to create the registry key entries for the vnc:// hyperlink. Do the same thing you did for RDP.

    Windows Registry Editor Version 5.00
    [HKEY_CLASSES_ROOT\vnc]
    @="URL:VNC Connection"
    "URL Protocol"=""
    [HKEY_CLASSES_ROOT\vnc\DefaultIcon]
    @="c:\\progra~1\\VNC\\vncviewer.exe"
    [HKEY_CLASSES_ROOT\vnc\shell]
    [HKEY_CLASSES_ROOT\vnc\shell\open]
    [HKEY_CLASSES_ROOT\vnc\shell\open\command]
    @="wscript.exe C:\\WINDOWS\\vnc.js %1"

So vnc://fqdn will execute c:\Program Files\vnc\vncviewer.exe fqdn. Adjust as needed if you saved vncviewer.exe to another location or use a different VNC client..

TELNET

Finally, telnet should work on its own, as long as you have enabled the telnet client feature. But that would be too easy, or I wouldn’t be blogging about it, would I? This time, instead of creating a js, we just need to enable the telnet client feature.

  1. Start, Control Panel, Programs and Features.
  2. Turn Windows features on or off
  3. Scroll down, and check the Telnet Client.
  4. Hit OK.

Then, we need to enable telnet links to work in IE. Chrome and Firefox should not need this step. Create another reg file using the contents below, and double-click it to import the settings.

    Windows Registry Editor Version 5.00
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_DISABLE_TELNET_PROTOCOL]
    "iexplore.exe"=dword:00000000

Viola. Four remote links can now be used for your admin pleasure. As far as the actual links are concerned, the html is fairly straightforward. Here’s an example if you are rolling your own.

    <A HREF="rdp://server1.example
    .com">rdp to server1</A> <br>

While Windows can figure out when you click a hyperlink what to now do, if you are creating hyperlinks in an Office document, you will still have to manually create them.

All of these were tested using Windows 7 Ultimate, Office 2007, IE8, Chrome, and Firefox 3.5.

While I did figure out how to make SSH work with PuTTY, and how to enable TELNET in IE8, and I corrected/took liberties with the VNC example, this is NOT original content produced by my neurons. Thanks and credit go to the Electronic Samurai RogierG for the brains behind this.

Update:
A reader encountered an issue with the telnet shortcut, but came up with a workaround. His email follows, and as you can see, he chose to use putty for telnet as well as ssh.

G’Day Ed,
     Despite my efforts and head scratching I could not get the Telnet version to work either. In the end I created telnet.reg

  • Windows Registry Editor Version 5.00
    [HKEY_CLASSES_ROOT\telnet]
    @="URL:Telnet Connection"
    "URL Protocol"=""
    [HKEY_CLASSES_ROOT\telnet\DefaultIcon]
    @="C:\\WINDOWS\\putty.exe"
    [HKEY_CLASSES_ROOT\telnet\shell]
    [HKEY_CLASSES_ROOT\telnet\shell\open]
    [HKEY_CLASSES_ROOT\telnet\shell\open\command]
    @="wscript.exe C:\\WINDOWS\\telnet.js %1"

and telnet.js

  • var destination=(WScript.Arguments(0))
    var search=’telnet://’
    var sshexe=’C:\\WINDOWS\\putty.exe’
    //WScript.Echo(destination)
    destination=destination.replace(search, ”)
    destination=destination.replace(‘/’, ”)
    var ws = new ActiveXObject("WScript.Shell")
    //WScript.Echo(sshexe + " " + destination)
    ws.Exec(sshexe + " " +  destination)

and did exactly as you suggested for ssh and rdp and it worked a treat.
As you can see, I didn’t even bother to change the variable names in the .js file … That’s just how lazy I have become.
Also putty.exe is now used for telnet as well as ssh.
Any how, I thought that might be a good addition to your blog as others may meet the same challenge.
Again thank you for the post it has been incredibly helpful.
Cheers,
Epic.

Thanks for the information Epic!

You might also enjoy:

  1. Enabling IPSec VPN connections to ISA 2006
  2. Enabling BitLocker for Windows 7
  3. Enabling telnet links in Internet Explorer 7
  4. Automatically backing up an ISA server’s configuration

{ 4 comments… read them below or add one }

Epic 2009-12-01 at 23:32

G’Day Ed … I am getting an error with your ssh.js (Invalis Character = line 2 Char 12 to be exact)
I see no reason why this is the case and have tried to run it on a couple of different machines.

I am making a central management point in Flash and have been having trouble getting Telnet and SSH to work. If I could get past this hurdle my project is almost done.

Reply

Epic 2009-12-01 at 23:51

It seems that it had something to do with the style of single quotes used when I cut and pasted the code as when I changed them all it made it past that line, but it is now getting an error that it can not find the file specified (line 9 char 1). What file is it refering to?

Reply

Epic 2009-12-02 at 00:00

HA … Just placed the putty.exe in a different place. All solved. Thank you for this it has been most helpful.

Reply

Ed Fisher 2009-12-02 at 10:20

Epic,
Glad things worked out for you. Not sure why the quote style messed you up…I copied from Chrome and pasted using PSPad and things were happy….if you are following comments, please let me know the browser and editor. And I would love to see the Flash app you are making if you care to share.
Cheers,
Ed

Reply

Leave a Comment

CommentLuv Enabled

Previous post:

Next post: