javascript 权限被 shell.application 拒绝
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 
原文地址: http://stackoverflow.com/questions/4496681/
Warning: these are provided under cc-by-sa 4.0 license.  You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
permission denied with shell.application
提问by jitendra
I have following javascript code to run notepade.exe:
我有以下 javascript 代码来运行 notepad.exe:
<SCRIPT type="text/javascript" LANGUAGE="JavaScript">  
  function executeCommands()
   {            
    var oShell = new ActiveXObject("Shell.Application");     
    var commandtoRun ="C:\WINDOWS\notepad.exe";
    oShell.ShellExecute(commandtoRun,"","", "open", "1");               
  }
</SCRIPT>
The problem is that, when i run the script then it give error..."Permission denied."
问题是,当我运行脚本时,它会给出错误...“权限被拒绝”。
Can anybody help me on this matter?
有人可以帮我解决这个问题吗?
回答by caspian
It's necessary to have two settings turned on.
有必要打开两个设置。
- Enable unsigned ActiveX controls for the current zone
Tools > Internet Options > Security > Custom level...
Enable "ActiveX Controls and plug-ins" > "Initialize and script ActiveX controls not marked as safe for scripting" - Allow Active Content to run files
Tools > Internet Options > Advanced > Security Enable "Allow Active Content to run in files on My Computer"
** Make sure to close all your IE browser windows. 
- 为当前区域启用未签名的 ActiveX 控件
工具> Internet 选项> 安全性> 自定义级别...
启用“ActiveX 控件和插件”>“初始化和脚本未标记为脚本安全的 ActiveX 控件” - 允许活动内容运行文件
工具 > Internet 选项 > 高级 > 安全 启用“允许活动内容在我电脑上的文件中运行”
** 确保关闭所有 IE 浏览器窗口。 
回答by MAbraham1
You may experience a "Permission denied" error, which means that the browser will not let script execute outside the "sandbox". Try solving the issue by changing a security setting in the browser:
您可能会遇到“权限被拒绝”错误,这意味着浏览器不会让脚本在“沙箱”之外执行。尝试通过更改浏览器中的安全设置来解决问题:
- Internet Options, Advanced, Security:
 - "Allow Active Content to run in files on My Computer"
 
- Internet 选项、高级、安全:
 - “允许活动内容在我的电脑上的文件中运行”
 
The above is for IE, but most browsers have similar options.
以上是针对 IE 的,但大多数浏览器都有类似的选项。

