.bat通过javascript代码调用

时间:2013-03-19 18:31:56

标签: batch-file

我试图通过我的java脚本代码调用.bat文件... bat文件轮流调用java文件..但我面临一个错误调用.bat文件plz帮助....也给出了java类的mi错误.... 这是代码仪式吗?

    <html> 
       <head> 
                 <script language="JavaScript" type="text/javascript">  
                 MyObject = new ActiveXObject( "WScript.Shell" )  
                 function Runbat()   
                 {  
                  MyObject.Run("C:\\Documents and        Settings\\shraddha\\Desktop\\test.bat") ;  
       }  

          </script> 
            </head> 
           <body> 
          <h1>Run a Program</h1> 
                    This script launch the file any bat File<p> 
            <button onclick="Runbat()">Run bat File</button> 
        </body> 
              </html> 

1 个答案:

答案 0 :(得分:2)

这是您正确格式化的代码。请注意,您的HTML缺少结束</p>代码和DOCTYPE。

<html>
    <head>
        <script language="JavaScript" type="text/javascript">
            MyObject = new ActiveXObject("WScript.Shell")
            function Runbat()
            {
                MyObject.Run("\"C:\\Documents and Settings\\shraddha\\Desktop\\test.bat\"");
            }
        </script>
    </head>
    <body>
        <h1>Run a Program</h1>
        This script launch the file any bat File<p>
        <button onclick="Runbat()">Run bat File</button>
    </body>
</html>

有关您的HTML问题,请参阅http://validator.w3.org/