How to check if the program is running with Administrator privileges in JavaScript

爱⌒轻易说出口 提交于 2019-11-30 16:02:57

问题


Is there any way to check in JavaScript if the current program runs with administrative privileges?

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);

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...

Thanks


回答1:


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.

I fear you have to rely on other techniques, like Flash or Java, then retrieve the value with Javascript.



来源:https://stackoverflow.com/questions/10795857/how-to-check-if-the-program-is-running-with-administrator-privileges-in-javascri

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!