Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom URI protocol designed to open explorer

We have an application designed for google chrome where we need to add a link to the network file share. Unfortunately, Chrome denies the file:// protocol for security purposes. We want to set up a custom protocol to allow this functionality.

I thought a good way to do this would be to call explorer. Here are the registry keys we added:

[HKEY_CLASSES_ROOT\MyApp\DefaultIcon]
@="\"C:\\Windows\\explorer.exe\""

[HKEY_CLASSES_ROOT\MyApp\shell]

[HKEY_CLASSES_ROOT\MyApp\shell\open]

[HKEY_CLASSES_ROOT\MyApp\shell\open\command]
@="\" C:\\Windows\\explorer.exe\" \"%1\""

Currently, we get an error that states the protocol isn't valid. Could anyone assist in correcting this?

Thank you all very much in advance.

like image 562
RKKC Avatar asked Apr 05 '17 15:04

RKKC


People also ask

What is custom protocol handler?

- LS. Method of allowing a webpage to handle a given protocol using navigator. registerProtocolHandler . This allows certain URLs to be opened by a given web application, for example mailto: addresses can be opened by a webmail client.

What is a protocol handler Windows?

Protocol handlers give the Windows Search indexer access to data stores, enabling the indexer to crawl the nodes of a data store and extract relevant information to index. Windows Search, for example, ships with protocol handlers for file system stores and for some versions of both Microsoft Outlook data stores.

How do I register a protocol handler?

Go to https://protocol-handler.glitch.me/, install the PWA, and reload the app after the installation. The browser has now registered the PWA as a handler for the web+coffee protocol with the operating system.


1 Answers

@ 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.

like image 88
mdbxz Avatar answered Oct 02 '22 21:10

mdbxz