Goro
Goro

Reputation: 10249

How to launch an application from a browser?

Is it possible to launch an application from a browser? I am not talking about opening a file from a browser (like open a PDF with Adobe Reader), but rather opening a new (blank) instance of an application that is installed on the user's machine.

Hypothetical situation: User browses a website that lists computers that can be managed via RDP. He clicks on a link to 192.168.1.10, that link opens Microsoft RDP client (mstsc.exe) with that ip address already filled out.

I am talking strictly about Windows universe.

Is that thing even doable outside of ActiveX and IE?

Is it wise to attempt this in IE with ActiveX?

Upvotes: 131

Views: 290736

Answers (8)

Reza Aslejeddian
Reza Aslejeddian

Reputation: 371

I was able to achieve this by an approach which is mentioned here, But You will need to add deep linking to the application, If that's not your app try finding It's deep linking docs.

Upvotes: 0

Abhijith C R
Abhijith C R

Reputation: 1610

The correct method is to register your custom URL Protocol in windows registry as follows:

[HKEY_CLASSES_ROOT\customurl]
@="Description here"
"URL Protocol"=""

[HKEY_CLASSES_ROOT\customurl\shell]

[HKEY_CLASSES_ROOT\customurl\shell\open]

[HKEY_CLASSES_ROOT\customurl\shell\open\command]
@="\"C:\\Path To Your EXE\\ExeName.exe\" \"%1\""

Once the above keys and values are added, from the web page, just open customurl://parameter1=xxx&parameter2=xxx. You will receive the entire url as an argument to the exe, which you'll need to process inside your exe. Replace 'customurl' with the text of your choice.

Upvotes: 92

carl
carl

Reputation: 433

@AbhijithCR 's reply works well. To register the protocol via a .bat file, do something like this

set key=customurl 
reg add HKCR\%key% /ve /d "URL:Description" 
reg add HKCR\%key% /v "URL Protocol" /d "" 
reg add HKCR\%key%\shell 
reg add HKCR\%key%\shell\open 
reg add HKCR\%key%\shell\open\command /ve /d ""c:\path to\your.exe" ""%%1"""

For me getting all the quotes and the double percent signs right was the tricky part.

Upvotes: 13

LiriB
LiriB

Reputation: 822

You can use SilverLight to launch an application from the browser (this will work only on IE and Firefox, newer versions of chrome don't support this)

Example code here

Upvotes: -7

zildjohn01
zildjohn01

Reputation: 11515

I achieved the same thing using a local web server and PHP. I used a script containing shell_exec to launch an application locally.

Alternatively, you could do something like this:

<a href="file://C:/Windows/notepad.exe">Notepad</a>

Upvotes: -17

brendan
brendan

Reputation: 29976

You can't really "launch an application" in the true sense. You can as you indicated ask the user to open a document (ie a PDF) and windows will attempt to use the default app for that file type. Many applications have a way to do this.

For example you can save RDP connections as a .rdp file. Putting a link on your site to something like this should allow the user to launch right into an RDP session:

<a href="MyServer1.rdp">Server 1</a>

Upvotes: 12

pastjean
pastjean

Reputation: 1317

Some applications launches themselves by protocols. like itunes with "itms://" links. I don't know however how you can register that with windows.

Upvotes: 8

Byron Whitlock
Byron Whitlock

Reputation: 53850

We use a sonicwall vpn. It launches a java applet that launches mstc with all the credentials setup. You really can't do this without a java applet or activex plugin.

Microsoft uses this technique itself on their small business server for getting inside the network. I wouldn't say it is a terrible idea, as long as platform independence isn't important.

Upvotes: 3

Related Questions