Permission denied error while executing shell command from JavaScript

I am trying to run shell command to open notepad from JavaScript. This is how my code looks like:

 <script type="text/javascript">
     function runNotepad() {
        var oShell = new ActiveXObject("Shell.Application");
        var commandtoRun = "C:\\WINDOWS\\Notepad.exe";
        oShell.ShellExecute(commandtoRun, null, "", "open", "1");
        }
 </script>

When i try to run this, it throws me an error saying Microsoft JScript runtime error: Permission denied.

I also have set Allow active content to run in files on my computer in IE but still no luck.

Any idea what am i missing here?

Answers


Any idea what am i missing here?

No browser would allow JavaScript to arbitrarily start a process. This functionality is not available in Internet Explorer because of the security implications.

This will work if run from other Scripting Hosts, such as cscript, but not Internet Explorer.


You can't run or create native objects inside webpage javascript. The idea is that if someone could do that, then they could create a FileSystem object. Then, while you idly browse their webpage, they play havoc with your file system.

If you need to do this, and have the file saved on the host's machine, save it as an HTML app (*.hta).


Need Your Help

Simulating the accelerometer event feature in Firefox 3.6?

firefox accelerometer firefox3.6

I just downloaded Firefox 3.6 today and I noticed in the list of new features they have an Orientation API that can detect the direction that your laptop/computer is tilted. This is clearly a hard...

Report Direct3D memory usage

windows memory direct3d video-memory

I have a Direct3D 9 application and I would like to monitor the memory usage.