colliyojiya
colliyojiya

Reputation: 1

.bat calling through javascript code

i m trying to call a .bat file through my java script code...the bat file in turns calls a java file..but i m facing an error with the calling of .bat file plz help....also it gives mi error with the java class.... is this code rite??

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

Upvotes: 0

Views: 17208

Answers (1)

David Ruhmann
David Ruhmann

Reputation: 11367

Here is your code formatted properly. Note that your HTML is missing the closing </p> tag and 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>

See http://validator.w3.org/ for your HTML issues.

Upvotes: 2

Related Questions