Detect if Java application was run as a Windows admin

前端 未结 8 2083
天命终不由人
天命终不由人 2020-11-27 05:37

I have a Java application. Is there anyway I can tell if the process was run with admin privileges, on Windows 7.

8条回答
  •  余生分开走
    2020-11-27 05:54

    The method from the answer marked best worked nicely for me until the point when I had to build the code in Jenkins on a Linux machine. com.sun.security.auth.module.NTSystem() is not available there and using sun packages is generally considered a bad practice: link

提交回复
热议问题