Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to config IE to make "wscript.shell" work

Tags:

javascript

I have some code that used to work. But I today when I try it again. I kept got "[object error]".

I thought it's the problem of IE safety configure. But I can find how to config IE to make it work.

function Run() {
  try   {
    var objShell = new ActiveXObject("wscript.shell");
    objShell.Run("calc");
  } catch(e) {
    alert(e);
  }
}
like image 458
ablmf Avatar asked Jan 26 '10 07:01

ablmf


3 Answers

You must enable ActiveX:

  • Click on Tools
  • Select Internet Options...
  • Select Security tab.
  • Select Internet in Web content zone.
  • Then, click on Custom Level...
  • Go through all the ActiveX setting there, select Prompt or Enable
like image 162
Darin Dimitrov Avatar answered Nov 10 '22 15:11

Darin Dimitrov


it is Case Sensitive !!

<html>
<head>
<script language="javascript" type="text/javascript">
function OpenFile(){
alert ('Work');
var x = new ActiveXObject("WScript.Shell");
x.run('calc.exe');
}
</script>
</head>

<body>

<input  type="button" value="GG"  href="#" onclick="javascript:OpenFile();">
</body>
</html>
like image 23
houssam Avatar answered Nov 10 '22 15:11

houssam


It may be necessary to make a change to the IE settings:

For example, for the Local intranet zone, you typically need to change a custom setting to "Initialize and script ActiveX controls not marked as safe for scripting."

I couldn't get the sample above to run without making the change.

like image 4
RK4299 Avatar answered Nov 10 '22 14:11

RK4299