Reputation: 79
I want to open local apps like skype from a html button, i have read a lot of stuff about that, but they dont work because the browsers dont let me do it, the browsers' newest versions dont allow to do that, and I know you are gonna tell me to do some other things instead doing this in order to open local apps, but I cant, I have to do exactly this way, it is a project from uni, the below is my code:
//I have done this but it doesnt work
<a href="file:///C:/Program%20Files%20(x86)/Skype/Phone/skype.exe"><button>Open App</button></a>
//I have done this but it doesnt work
<a style="Content-Type: application/octet-stream" href="file:///C:/Windows/notepad.exe"
type="application/octet-stream">Open App</a>
//I have done this but it doesnt work
<button onclick="RunFile();">Open App</button>
<script type="text/javascript" language="javascript">
function RunFile() {
WshShell = new ActiveXObject("WScript.Shell");
WshShell.Run("C:/windows/notepad.exe", 1, false);
}
</script>
//I have done this but it doesnt work
<input type="button" value="Run Notepad" onclick="RunProgram"/>
<script language="VBScript">
Sub RunProgram
Set objShell = CreateObject("Wscript.Shell")
objShell.Run "notepad.exe"
End Sub
</script>
I need to use Firefox or chrome and i this ActiveX is used by IE
Upvotes: 1
Views: 5132
Reputation: 1321
You can do this with a custom protocol handler. Your "button" could then just be a link:
<a href="mycustomprotocol:foobar">Click to open app</a>
To make this actually function you'll need to register the app on the computer that is opening the link. If you're writing the app then you'd probably do that during the installation. How to register the app depends on the operating system. There's an article on it here.
As an example of this working in the wild, the skype meeting I just joined used the following url:
<a href="lync15:confjoin?url=https%3A%2F%2Fwebpoolblu0b10.infra.lync.com%2FMeet%2F%3Forigurl%3DaHR...">
And here are the corresponding registry entries that allow it to open:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Lync15]
@="URL:lync15 Protocol"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\Lync15\DefaultIcon]
@="C:\\PROGRA~1\\MICROS~1\\Office16\\lync.exe"
[HKEY_CLASSES_ROOT\Lync15\shell]
[HKEY_CLASSES_ROOT\Lync15\shell\open]
[HKEY_CLASSES_ROOT\Lync15\shell\open\command]
@="C:\\PROGRA~1\\MICROS~1\\Office16\\lync.exe \"%1\""
Upvotes: 1
Reputation:
You can't. Neither linking to file://
URLs nor creating ActiveX objects that aren't marked safe for scripting (like WshShell
) are allowed in modern web browsers. Most of them don't support VBScript or ActiveX at all, in fact.
If you have been told you need to do this for a university course, the course is teaching outdated material. We can't fix that.
Upvotes: 0