Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating Custom Protocol (Windows 7)

I've been trying to create a custom protocol (open_php_file://) to open local files through the browser. I've created the following registery-keys:

HKEY_CLASSES_ROOT
     open_php_file
          (Default) = "URL:PHPEd protocol"
          URL Protocol = ""
          DefaultIcon
               (Default) = "phped.exe"
          shell
               open
                    command
                         (Default) = "C:\Program Files (x86)\NuSphere\7.0\phped.exe" "%1"

The problem is: I can't open files in my browser (example: open_php_file://c:\file.txt), and the protocol isn't listed in the windows default programms.

like image 899
Simon Avatar asked Jul 26 '12 14:07

Simon


People also ask

How do I create a custom protocol?

Use the Filter Components > Protocols > Add Protocol page to define a new, custom protocol. 1. Enter a Name for the protocol. A custom protocol can be assigned the same name as a pre-defined protocol, in order to extend the number of IP addresses or ports associated with the original protocol.


1 Answers

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\openphpfile]
@="\"URL:openphpfile Protocol\""
"EditFlags"=hex:02,00,00,00
"URL Protocol"=""

[HKEY_CLASSES_ROOT\openphpfile\DefaultIcon]
@="\"C:\\Users\\ABC\\Documents\\Programs\\CB\\Chunks\\CGI.exe\",0"

[HKEY_CLASSES_ROOT\openphpfile\shell]

[HKEY_CLASSES_ROOT\openphpfile\shell\open]

[HKEY_CLASSES_ROOT\openphpfile\shell\open\command]
@="\"C:\\Users\\ABC\\Documents\\Programs\\CB\\Chunks\\CGI.exe\" -c \"%1\""

Basically the problem was with the underscores in your protocol.Once removed everything started working fine.You can change the path of executable as per your wish i.e. "C:\Program Files (x86)\NuSphere\7.0\phped.exe".

I tried openphpfile:blast and it worked quite nicely :)

EDIT:

the problem with this solution is that %1 gets replaced with "open_php_file://[file]" instead of just "[file]". This way I need some sort of filter that chops "open_php_file://".

put a space after openphpfile:[Space]Your_Content and change parameter to %2 you will get the expected result

[HKEY_CLASSES_ROOT\openphpfile\shell\open\command]
@="\"C:\\Users\\ABC\\Documents\\Programs\\CB\\Chunks\\CGI.exe\" -c \"%2\""
like image 101
perilbrain Avatar answered Oct 01 '22 22:10

perilbrain