Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

protocol handler

Requirement: We want to launch an external compare tool (like BeyondCompare or WinMerge) from a web page, through a button or link. The text file paths should be passed to the tool on its launch, so it understands them and opens them in the left and right side comparison panels.

Tried Solutions:

1) Using JavaScript's ActiveXObject: With this the user can simply click a button/link and launch the compare tool installed on its machine. But it works only in Internet Explorer, so we cannot go with this.

Ref: How to run an external program, e.g. notepad, using hyperlink?

2) Using Java Applet: Due to security reasons, applets embedded in a browser are not permitted to access the local file system and it will throw the "Access Control Exception". Hence, we cannot go with this too.

Ref: Why is my applet throwing an AccessControlException?

3) Using Protocol Handler: We can set up a custom URL protocol to trigger the program. Like how we've the mailto:[email protected] syntax used to create email links, this will automatically launches Outlook on Windows. "mailto" is a predefined protocol in Windows Registry.

Similarly we created our own protocol, say "launchCompareTool" in the registry and were able to launch any application like WinMerge or BeyondCompare. However, we're unable to achieve passing left and right side file paths as arguments to the application. May be the application getting launched need to expect these arguments.

Ref: http://www.dreamincode.net/forums/topic/220444-run-program-from-server-on-client-computer/ http://msdn.microsoft.com/en-us/library/aa767914%28v=vs.85%29.aspx#app_reg

Unlike the "mailto" protocol, which has "body" and "subject" arguments passed to mail client (like Outlook), which understands them. These compare tools are not having such arguments that can be passed from protocol.

Is there another way we can meet this requirement?

Thanks, Abdul

like image 511
Abdul Rahim Khan Avatar asked Sep 18 '12 06:09

Abdul Rahim Khan


2 Answers

Yet another approach recently coined to perform the same. Basically this new approach relays on creating a Handler application, which is nothing but a Windows console based ClickOnce application. The ClickOnce Handler application will acts as an interceptor between the Host (a web page or outlook or anything that can embedd the link) and the Target app (like WinMerge or Beyond Compare). The Handler application will be invoked on the click of the embedded link in the host application. The Link is nothing but a http url that will hold the information in the querystring parameter. Since the handler application is ClickOnce deployed so it allows itself to be publish to a Web server. The embedded link (HTTP URL) will invoke the handler application and then handler application will parse the received query string parameters and finally invoke the relevant target application. Handler application can be thought of as a Click Once Deployed parser application. Following is the detailed article with code example at Custom-HyperLinks-Using-a-Generic-Protocol-Handler.

Anshul Mehra

like image 63
Anshul Mehra Avatar answered Dec 22 '22 07:12

Anshul Mehra


The custom url can call a dos batch file or vbscript which parses the arguments and then calls winmerge.

like image 44
Brian McGinity Avatar answered Dec 22 '22 07:12

Brian McGinity