Launch an application using HTML

6k Views Asked by At

I know that

<a href = 'ymsgr:sendim?contactID'>Send me a message</a>

will launch Yahoo Messenger.

can I create something like this to launch MSWord or my own application?

2

There are 2 best solutions below

0
On BEST ANSWER

Here is an explanation of what you're describing: https://stackoverflow.com/a/16586294/4500419

And here you can find the URI specifications for Microsoft Office: https://msdn.microsoft.com/en-us/library/office/dn906146.aspx#sectionSection4

So, something like

ms-word:ofv|u|http://yoursite.com/document.docx

Would open document.docx in read-only mode in MS Word.

And here's the doc on how to register your own application to a URI scheme in Windows: https://msdn.microsoft.com/en-us/library/aa767914%28v=vs.85%29.aspx

2
On

This works also by simply naming the html file .hta which is fine if its for a local project

<html> 
<head> 
<title>Application Executer</title>
<HTA:APPLICATION ID="oMyApp"     APPLICATIONNAME="Application Executer"      BORDER="no"     CAPTION="no"    SHOWINTASKBAR="yes"     SINGLEINSTANCE="yes"    SYSMENU="yes"   SCROLL="no"     WINDOWSTATE="normal">
 <script type="text/javascript" language="javascript">
 function RunFile() {       WshShell = new ActiveXObject("WScript.Shell");      WshShell.Run("c:/windows/system32/notepad.exe", 1, false); } 
</script>
 </head>
 <body> 
    <input type="button" value="Run Notepad" onclick="RunFile();"/> 
</body> 
</html>