首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用javascript运行Apache服务器中的批处理文件

使用javascript运行Apache服务器中的批处理文件
EN

Stack Overflow用户
提问于 2013-10-01 04:20:58
回答 1查看 2.3K关注 0票数 1

我们试图使用java脚本运行apache服务器中的bat文件。我们收到以下错误:“自动化服务器无法创建对象”--请找到下面的代码,并让我们知道如何解决这个问题

代码语言:javascript
复制
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <script>    
    function testing() {
        alert("Execution will start");
        WshShell = new ActiveXObject("WScript.Shell");
        alert("after webShell");
        //var commandtoRun = "C:\\Program Files\\Apache Group\\Apache2\\htdocs\\application\\gui\\templates\\execute\\test.bat";

        WshShell.Run ("\"C:\\Program Files\\Apache Group\\Apache2\\htdocs\\application\\gui\\templates\\execute\\test.bat\"");

        alert("after webShell");

    }

    </script>

</head>


    enter code here
    <body> 

    <form>

    <p id="demo">Running scripts </p>
    <input type="button" onclick="javascript: testing ();" value="Run Scripts" />
    <button onclick="javascript: testing ();">Run bat File</button>

    </form>
    </body>

    </html>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-10-01 04:30:10

JavaScript在客户端执行。您所提供的位置将引用客户端计算机。要么将文件放在指定位置的客户端,要么编写服务器端代码。如下所示。我希望你在用jsp。

例如:

代码语言:javascript
复制
    <% String script="Write your script"%>
    <script> 
function testing(var script) {        
        WshShell = new ActiveXObject("WScript.Shell");              
        WshShell.Run (script);       
    }

var script1=<%=script%>
testing(script1);

    </script>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19107912

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档