如何检查程序是否在JavaScript中管理员权限运行 [英] How to check if the program is running with Administrator privileges in JavaScript
问题描述
有没有办法在JavaScript中检查当前程序具有管理权限运行?
Is there any way to check in JavaScript if the current program runs with administrative privileges?
例如在C#中我可以用下面的code做到这一点:
For example in C# i can do it with the following code:
bool isRunningWithAdminApprovals;
WindowsIdentity identity = WindowsIdentity.GetCurrent();
WindowsPrincipal principal = new WindowsPrincipal(identity);
isRunningWithAdminApprovals = principal.IsInRole(WindowsBuiltInRole.Administrator);
不过,我需要使用带有JavaScript的当前运行脚本来检查它。
如果我尝试运行exe文件或C#code的包装,UAC的提示我赞成它,然后我将已经行政的privilages ...
However I need to check it with a current running script of javaScript. If i try to run an exe or a wrapper of the C# code, the UAC will prompt me to approve it and then i will already be in Administrative privilages...
感谢
推荐答案
在现代浏览器,JavaScript环境在沙盒中运行,所以有没有办法可以知道,除了这些事情有关系统的任何东西,把浏览器中的沙箱,即用户代理字符串和多一点。
In modern browsers, the Javascript environment is run in a sandbox, so there's no way you can know anything about the system except those things that the browser put in the sandbox, ie the user agent string and a little more.
我怕你不得不依靠其他技术,如Flash或Java,然后检索与Java语言的价值。
I fear you have to rely on other techniques, like Flash or Java, then retrieve the value with Javascript.
这篇关于如何检查程序是否在JavaScript中管理员权限运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!