1

All,

I have a java script file that opens a notepad file but getting undefined object error. I feel this is something to do with security but not sure.. Could you please advise?

Note: Calling run function on click of a button. Error: Uncaught ReferenceError: ActiveXObject is not defined In IE - I am able to get alert 4 but can not see notepad but in Chrome getting stuck at alert 1 only.

<script language="JavaScript" type="text/javascript">
    function run() {
        alert("step 1");
        var oShell;
        oShell = new ActiveXObject("Shell.Application");
        alert("step 2");
        var commandtoRun = "c:\\windows\\system32\\notepad.exe";
        alert("step 3");
        oShell.ShellExecute(commandtoRun, "", "", "open", "1");
        alert("step 4");
    }
</script>
2
  • In Microsoft's own documentation Creating an ActiveXObject on a remote server is not supported in Internet Explorer 9 standards mode, Internet Explorer 10 standards mode, Internet Explorer 11 standards mode, and Windows Store apps or later. Commented Jul 30, 2015 at 21:45
  • In Chrome - you are getting stuck at alert1 beacuse ActiveXObject is not supported in other browsers. <br/>In IE - you are getting stuck at alert4 - because your browser is not having the permission to run the exe's. You get permission denied error. Commented Jan 8, 2016 at 9:15

1 Answer 1

2

ActiveXObject is a proprietary Microsoft feature and is not supported in any browser other than Internet Explorer.

Other web browsers do not allow webpages to run arbitrary programs under any circumstances.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! got it ... one query though... at least in IE, I should be able to open the notepad ? if I am able to see the step 4 alert ? Is something wrong I am doing ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.