问题
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