Javascript 从网页打开应用程序

Javascript 从网页打开应用程序,javascript,windows,internet-explorer,hta,Javascript,Windows,Internet Explorer,Hta,我使用以下命令从网页打开记事本: <html> <head> <title>Application Executer</title> <HTA:APPLICATION ID="oMyApp" APPLICATIONNAME="Application Executer" BORDER="no" CAPTION="no" SHOWINTASKBAR="yes"

我使用以下命令从网页打开记事本:

<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:\Program Files\Notepad++\notepad++.exe", 1, false);
        }
    </script>
</head>
<body>
    <input type="button" value="Run Notepad" onclick="RunFile();"/>
</body>
</html>
让我觉得错误在于应用程序的类型

是否有可以使用此方法打开的应用程序列表?如何使用此方法打开Microsoft应用程序、word/excel和其他应用程序

两个问题:

  • 如果路径包含空格,则需要用引号将其括起来
  • 这是JavaScript,因此字符串中的
    \
    是一个特殊字符,用于指示转义序列,要将
    \
    放入字符串中,必须将其本身转义为
    \
  • 使用:

    WshShell.Run("C:\Program Files\Notepad++\notepad++.exe", 1, false);
    
     WshShell.Run('"C:\\Program Files\\Notepad++\\notepad++.exe"', 1, false);