polino247
polino247

Reputation: 51

Running a batch file using JavaScript in web browser

I'm having a nightmare here, please help.

Here is my JavaScript:

<script language="javascript">
    function MyCmd();
    var shell = new ActiveXObject("Shell.Application");
    var appExe =  @"D:/ping.bat";
    shell.ShellExecute(appExe , "", "", "open", "1");
</script>

I call this function from inside a <td> in a table..

<button style="width:relative; height:65"  onClick="MyCmd()"><b>Netstat</b></button>

All I want is to see the batch file running. Content of the batch file is: netstat > ping.bat, and it's located on d:\. Any ideas?

Upvotes: 0

Views: 1972

Answers (2)

jwheron
jwheron

Reputation: 2562

Echoing what others have said: this is a terrible idea. Even if you have created something harmless, how is the browser supposed to know that?

I cannot imagine why this is such an emergency. You need to take a step back and think about other ways to do what you want. If you're trying to create a program to execute a batch file, a webpage is a totally inappropriate place for that program.

Upvotes: 0

Svante Svenson
Svante Svenson

Reputation: 12488

The code you supplied can only be made to run in Internet Explorer when set to lowest security as well as when UAC is turned off or an OS without UAC is used.

If you intended to get this running on the server, it's probably possible but a completly other question.

Upvotes: 2

Related Questions