updated 20110615
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.
- Start, Control Panel, Programs and Features.
- Turn Windows features on or off
- Scroll down, and check the Telnet Client.
- 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:






{ 28 comments… read them below or add one }
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.
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?
HA … Just placed the putty.exe in a different place. All solved. Thank you for this it has been most helpful.
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
hey Ed, thanks it worked after some little bit troubleshooting with *.js file.
-r
Glad it helped R, but what troubleshooting was required? Share the love, and help another!
The *.js file for mstsc should be:
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)
Thanks Jon,
Looks like my editor got smarter than me with smart quotes too. Scripts updated in the body.
Cheers,
Ed
Thanks alot…..works fine using Internet Explorer……only problem is I never use internet explorer. Is there a way for this to work with Google Chrome?
Not sure you would need anything different as long as Chrome is your default app for those URLs, but I am not in a location or with a machine I can test. Give me to the weekend and I will see what I can find. If you figure it out before hand, let me know.
Assuming Chrome is your default browser, what happens when you click a link?
I got it working…..but only when you click on it as a hyperlink. If you put it in the address bar it google searches for RDP.
Excellent, glad it is working for you, and thanks for letting me know.
This is just what I needed for an internal project I was working on. Needed to spawn the appropriate viewer for either RDP or VNC.
Firefox and IE had work-arounds, but I primarily use Chrome. This works in all. Great stuff!
Excellent, thanks for letting me know!
Hi
am trying to add the rdp one and when i type in rdp://fqdn, it shows this following error
“—————————
Windows Script Host
—————————
There is no script engine for file extension “.js”.
—————————
OK
Am i doing something wrong please let me know
Thanks
Raki
Have you associated .js files with another application? Try this. Right-click on a .js file in Windows Explorer, choose “Open with” and then choose “Choose default program”, and make sure the default program is “Microsoft Windows Based Script Host”.
If that doesn’t work, try this from an admin cmd prompt.
regsvr32 %systemroot%\system32\jscript.dll [enter]
HTH
Ed
Hi.
This is a great solution and works fine with rdp, but the ssh solution produces a Windows error :
Line 5 char 45 :
Unterminated string constant
when running it on our Win XP Prof.
I’ve cut&pasted and also tried manual creation of the js file but the error remains.
Ive also updated my java from java.com but the error message won’t go away…. Any ideas ??
Gurra,
Looks like a font change on my theme turned double quotes into a pair of single quotes. I updated the post, try a copy/paste again and let me know.
Sorry for the boggle,
Ed
Yeah, great…. Works fine now !!
Excellent program !!!
Now I’m testing it on Win 7 Pro 64-bit SP1, but it complains about my link saying something like (trying to translate the message into English):
Error in connection file (rdp://10.1.5.3)
(i’m not 100% sure about the error message translation, but it complains about the rdp://10.1.5.3 which works just fine in Win XP, using exactly the same scripts)…
(mstsc.exr IS in c:\windows\system32 and works fine from the command line)
Is this a problem caused by some security issues in Win 7 ??
Works fine for me in Windows 7 Ultimate SP1…no binary difference in Ultimate and Pro as far as mstsc is concerned.
You might have something wrong in your default.rdg file. Try this
Start, run, mstsc /v:someserverofyours[enter]
If you get the same error, it’s in your default connection file, not in the js or regkey.
Run mstsc without a target, and then check all your default settings.
HTH
Ed
Re. Win7 ssh/rdp problem.
Seems to be a security problem after all.
I tested mstsc & ssh on command line and that worked fine.
In win7 i am user gurra and i am a member of group administrators. This results in the rdp-errors i mentioned earlier, but logging in as USER administrator makes the rdp/ssh links work fine.
Seems to be a difference in read/write rights between a user that is a member of the administrator group and the USER administrator.
Anyway everything works fine now. Thanks again for excellent programs !!
With respect Gurra, it sounds like a problem with your machine’s security, not Win7. On my machine I am using my domain account, which is a member of the local administrators group, and it works just fine. I do not need to log on as administrator, or even launch the process as an admin (no split token issue.)
As long as it is working for you, I’m glad, but you shouldn’t have to log on as the Administrator for this to work unless there is something more restrictive than default on your PC that we don’t know about.
Hope that helps,
Ed
Yepp.
It was a problem in my machine. I tested the same configuration on another machine & it worked fine.
Sorry for bothering you about this, I am very happy with your programs that solved a lot of time for me !!
(& sorry for a late reply)…
Gurra
Trying to get a hyperlink to launch a premade .vnc file, your site is so far the closest thing I have come across in my attempts to be abl eto do this. Love that it works but having to key in my password each time is a draw back. Hence my wanting to launch the .vnc file I have locally instead. Any ideas how this could be done?
What VNC client are you using, and are you sure you want to embed credentials in a file? For your local workstation, appropriately secured, I imagine that will be okay, but I wrote this with a web site map in mind (even though it started as a humble demo) so I never spent any time embedding creds…want each user to enter their own. If I use your client version, I will kick it around a bit and see what I can come up with. If I don’t, some other visitor might and can chime in.
Paste the contents of your file (without real username, password, or externally reachable host of course) so I can see what you’re working with.
Ed
Its RealVNC and the viewer is associated with the .vnc extension for these files:
[Connection]
Host=HOSTNAMEHERE
Password=PASSWORDHERE
[Options]
UseLocalCursor=1
UseDesktopResize=1
FullScreen=0
FullColour=0
LowColourLevel=1
PreferredEncoding=ZRLE
AutoSelect=1
Shared=0
SendPtrEvents=1
SendKeyEvents=1
SendCutText=1
AcceptCutText=1
DisableWinKeys=1
Emulate3=0
PointerEventInterval=0
Monitor=\\.\DISPLAY1
MenuKey=
AutoReconnect=1
That’s the contents of the vnc file. It is really just the password part that truly care about. I remotely connect to hundreds of client computers and having to type in the password for each would be a nightmare. End goal is a php webpage which a clickable div that launches the correct *.vnc file that is stored on my local pc.
Are you crafting that file by hand, or using the VNC client to create/save it? I believe Password=XXXXXXX is going to store that XXXXXX as an encrypted password (making me feel better about doing that) but I am not clear on whether you are editing a text file and adding the cleartext password, or creating the file with VNC so it salts/saves the PW encrypted.
The password is encrypted. The .vnc is editable via a text editor but the first was created via the vnc program.