Custom URI protocol designed to open explorer Custom URI protocol designed to open explorer windows windows

Custom URI protocol designed to open explorer


@ Wolfram Schmied,

I just wrote a workaround on yours, using CMD:

REGEDIT4[HKEY_CLASSES_ROOT\IntranetFileLauncher]@="URL:IntranetFileLauncher Protocol""URL Protocol"=""[HKEY_CLASSES_ROOT\IntranetFileLauncher\DefaultIcon]@="\"C:\\Windows\\explorer.exe\""[HKEY_CLASSES_ROOT\IntranetFileLauncher\shell][HKEY_CLASSES_ROOT\IntranetFileLauncher\shell\open][HKEY_CLASSES_ROOT\IntranetFileLauncher\shell\open\command]@="cmd /c set url=\"%1\" & call set url=%%url:intranetfilelauncher:=%% & call start explorer file:%%url%%"

The code above basically does the same as yours, except on the last line it uses cmd.exe to open a file/folder a command.In pseudo code: open commandpromt, pass given filepath as variable 'url', alter variable 'url' by stripping the protocol identifier and finally open explorer with the stripped filepath

I hope this helpes.


I got the following to work on Windows 8 / Firefox.

The correct way to register a custom protocol is described in this MSDN article.

Sadly, you cannot apply this directly to the Windows Explorer. If you do, you'll find that the Explorer starts spawning copies until either your memory or your patience runs out, and you'll have to log off to stop it. The reason is that the application handling the protocol is passed the entire link including the protocol specification. I. e., if you have a link

localdir:D:\somefolder,

the resulting call will not be

explorer D:\somefolder,

but

explorer localdir:D:\somefolder.

This is apparently done so that the same application can handle several protocols. But Explorer doesn't recognize that it is meant to handle the request, and instead starts the resolution process anew, which sets the vicious circle in motion.

To deal with this, you call a simple helper app that removes the protocol specification from the argument, and then calls Explorer with the cleaned string.

As an example, I created a bare bones Java class Stripper.

import java.io.IOException;public class Stripper {  public static void main(String[] args) {    String stripped = args[0].substring("localdir:".length());    try {       Runtime.getRuntime().exec("C:\\Windows\\explorer.exe "+stripped);    }    catch (IOException e) { /* error handling */ }  }}

The following is a .reg file adding the required keys to the registry. This assumes that Stripper is located in the folde D:\Stripper.

Windows Registry Editor Version 5.00[HKEY_CLASSES_ROOT\localdir]@="URL: localdir Protocol""URL Protocol"=""[HKEY_CLASSES_ROOT\localdir\shell][HKEY_CLASSES_ROOT\localdir\shell\open][HKEY_CLASSES_ROOT\localdir\shell\open\command]@="cmd /c \"cd /d d:\\Stripper & java Stripper %1\""

The command invokes the command line interpreter, telling it to first change to the directory containing our helper, and then to call the JRE to execute it. It's a bit awkward, but it works.

With a native .exe file, the command key could look like this:

[HKEY_CLASSES_ROOT\localdir\shell\open\command]@="<somepath>Stripper.exe %1"

This is a quick'n'dirty solution, you'll want to obviously want to add checks and balances and probably more mechanics, but the general approach looks workable.


Same task here, same solution first as @mdbxz and after with VBScript to not showing cmd black box:

Windows Registry Editor Version 5.00[HKEY_CLASSES_ROOT\explorer]@="URL:VIR Protocol""URL Protocol"=""[HKEY_CLASSES_ROOT\explorer\shell][HKEY_CLASSES_ROOT\explorer\shell\open][HKEY_CLASSES_ROOT\explorer\shell\open\command]@="mshta vbscript:Close(Execute(\"CreateObject(\"\"WScript.Shell\"\").Run Join(Array(\"\"iexplore.exe\"\",Replace(\"\"%1\"\",\"\"explorer\"\",\"\"https\"\"))), 1, True\"))"

The problem with these that if we click on same link in Explorer it handles the same, so it opens a new window, not just jump to the link. Also the question that if we want open the given app with the protocol.

Can we register the new protocol to Explorer, so it translate to https? Then we wont needed to replace protocol.