简体   繁体   English

从网页在Windows中启动应用程序

[英]Launching an application in windows from a webpage

I am working on a web based application at my work to make every once life easier. 我正在工作基于Web的应用程序,以使每一次生活都变得更轻松。 I am trying to build a page that would enable them launch the apps from with in the browser. 我正在尝试建立一个页面,使他们能够从浏览器中启动应用程序。 I was thinking I could use Windows Script Host Run Method, but I have never used any windows based scripting languages. 我当时以为我可以使用Windows脚本宿主运行方法,但是我从未使用过任何基于Windows的脚本语言。 So to sum up my issue here, I need to click on a launch button with in the browser to launch text pad or other programs on Windows. 因此,在这里总结我的问题,我需要在浏览器中单击启动按钮,以在Windows上启动文本板或其他程序。 Any help would be very appreciated. 任何帮助将不胜感激。

Thanks 谢谢

Update to question 更新问题

Here is a possible answer, 这是一个可能的答案,

 <script language="javascript" type="text/javascript">
  function runApp(){ 
   var shell = new ActiveXObject("WScript.shell"); 
   shell.run("notepad.exe", 1, True); 
  }
 </script>

<input type="button" name="button1" value="Run Notepad" onClick="runApp()" />

The only way for this to work legitimately is to have your users install a program prior to your website attempting to launch the program. 合法运行的唯一方法是让您的用户在您的网站尝试启动该程序之前安装该程序。 Your installation will register a URL Protocol . 您的安装将注册一个URL协议。 When the Web Browser sees a non-http type protocol it will attempt to load the registered program that accepts the URL protocol your website is requesting. 当Web浏览器看到非HTTP类型的协议时,它将尝试加载接受您网站请求的URL协议的注册程序。

Registering an Application to a URL Protocol 将应用程序注册到URL协议

您可以在HTML页面上对本地或UNC路径进行href操作。

  <a href="file:///c:/path/executable.exe">click here</a>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM