2013-10-01 2 views
1

Java 스크립트를 사용하여 Apache 서버에있는 bat 파일을 실행하려고합니다. 우리는 "는 개체를 만들 수 없습니다 자동화 서버"아래의 코드를 찾아주세요 우리가javadript를 사용하여 Apache 서버에있는 배치 파일 실행

<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> 
+0

정말 CGI가 아닌 ActiveX로 하시겠습니까? – Amadan

답변

0

자바 스크립트는 클라이언트 측에서 실행하는 문제를 해결하는 방법을 알 수 있도록 다음과 같은 오류를 얻고있다. u가 제공 한 위치는 클라이언트 시스템을 나타냅니다. 파일을 클라이언트 측의 지정된 위치에 두거나 서버 측 코드를 작성하십시오. 다음과 같이 jsp를 사용하고 싶습니다.

<% String script="Write your script"%> 
    <script> 
function testing(var script) {   
     WshShell = new ActiveXObject("WScript.Shell");    
     WshShell.Run (script);  
    } 

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

    </script>