Description
A client-side VB script that adds a right-click context menu to Windows explorer that forms correct confluence file:/// links and puts them in your clipboard for easy pasting.
We do a lot of linking to files on our "normal" Windows file system in our wiki pages. Currently with Confluence it is a bit of a multi-step pain to create a hyperlink to a file on your server. eg: There is no "Browse for file" link in the linking tool, and if you do make your own link with file:/// you need to convert all windows backslashes you copied from Explorer (or whatever) to forward slashes... this is very annoying.
This script adds a right-click context menu to Windows explorer labelled "Copy Wiki link to clipboard". It works for both files and directories. The context entry looks like this:

When you choose this option, the script creates a properly formatted link and puts it in your clipboard. In the above example, the created link looks like this server-noexamples.xml.config and was formed like this:
[server-noexamples.xml.config|file:///C:/confluence-2.1.3-std/conf/server-noexamples.xml.config]
Features of the created link are:
- The correct file:/// prefix is used
- Backslashes are converted to forward slashes
- An alias is created with file (or directory) name only... not the full path.
Once this is done, simply alt-tab (or whatever) back to the confluence page you are editing (in markup mode) and paste the link in.
Installation
- Download the zip file located here: CopyWikiLink.zip
- Extract the contained script
- It doesn't matter where you put the script, as long as you can leave it there forever. I put it in C:\Windows (or equivalent).
- Install the script
- To do this you just execute it (double-click it)
- You only ever do this once. Doing it again will uninstall it.
- Start using it!
If you want to uninstall it for some odd reason, just run it again - it toggles itself.
This works great on XP and NT, but it definitely has not been 100% tested on any other windows platform, but there is no reason I know why it shouldn't work.
Comments
| Hey Firefox users!!! Read this!! If you use Firefox you'll run into the problem everybody inevitably does — that the file:/// links don't work. For a while we resorted to the "Open in IE" extension (there are a few flavours), which wasn't too bad, but much better is...
|
| For the Security Conscious... A VB Script file is just a text file with a vbs extension... you can check out how the code works by just reading it in any text editor (eg: Notepad). The code is also below. Seeing the code is handy, since you should be nervous about anonymous strangers such as myself posting code that you are to run on your pc. I can assure you I'm 100% trustworthy (and only a little bit strange) and you can just run it and enjoy, but you're better off checking for yourself! This is one reason I made it as a VBS and not an exe, but the other was just for the fun of getting it to work as a VBS. |

Comments (6)
Nov 27, 2006
Chris W says:
This script sounds very handy, but... I get the following error when installing...This script sounds very handy, but... I get the following error when installing it (W2000 Pro). I don't have sysadmin privileges (company policy...) i.e. I cannot run regedit.exe and usually can't edit the registry.
Any workarounds?
Thanks!
Chris
Nov 27, 2006
Russell Warren says:
Without admin privileges (ouch!!) you can't modify the registry, which means my ...Without admin privileges (ouch!!) you can't modify the registry, which means my script can't add to the Explorer context menu. Or do much of anything else in Windows...
You'll have to get a sysadmin to take the 10 seconds it would take to run this script with the correct privileges. Once it is done once it will work forever.
Having said that, that error looks like it doesn't like it like the registry path that I'm changing on your system to get the context entry. Below is a shot of what the relevant registry entry should be as a result of the auto-install of the script.
I use "HKCR" in the script which works as a shortcut for "HKEY_CLASSES_ROOT", and I thought this always worked... it does for all machines so far in our company. Maybe try changing "HKCR" in the script to the exact "HKEY_CLASSES_ROOT"?
I highly doubt that is it, though. It is much more likely to be due to your company's employee hobbling policy.
Nov 27, 2006
Chris W says:
Russell, Thanks much for the quick reply and helpful advice. I replaced all HK...Russell,
Thanks much for the quick reply and helpful advice. I replaced all HKCR's with HKEY_CLASSES_ROOT in the script, but as you guessed, it didn't change much in the end:
Unfortunately there is little way around the company policy. Moreover I frequently change PC's and would thus have to have an admin do the trick for me several times. Ultimately, I'd like all my users to be able to install this script, and that won't happen if they need sysadmin support for it... Too bad!
Thanks for checking though, and who knows, maybe someone will come up with another (admin-less) solution?
Cheers,
Chris
Dec 21, 2006
Knox North says:
The link to the zip file seems to have become corrupt.The link to the zip file seems to have become corrupt.
Mar 28, 2007
Russell Warren says:
Weird. I just replaced the zip. Not sure why I didn't see this comment earlier...Weird. I just replaced the zip. Not sure why I didn't see this comment earlier... sorry for the delay.
Another option if it happens again (??!!?!?) is just to copy the source code I included into an appropriately named file (eg: CopyWikiLink.vbs). There is no need to get the zip.
Dec 13, 2007
Scott says:
Thanks! I thought this wasn't working at first because I didn't see the pop...Thanks!
I thought this wasn't working at first because I didn't see the popup "Allow Programmatic clipboard access". I eventually went to Internet options to permanently enable Allow Programmatic clipboard access.
I needed to paste the hyperlink directly into Excel and slightly modified the last few lines on your .vbs file to:
fName = fso.GetFileName(Args(0))
'msgbox "Fname = " & fName
buf = "file:///" & Replace(Args(0),"\","/")
'msgbox "clip = " & buf