简体   繁体   English

Java - 获取 Windows 登录用户

[英]Java - get windows logged user

I'm logged in to windows 10 with a regular user (no admin privileges).我以普通用户(无管理员权限)登录到 Windows 10。 I run my java application with admin privileges, but I need to get the normal logged-in user path (that's unprivileged) at runtime.我以管理员权限运行我的 java 应用程序,但我需要在运行时获取正常的登录用户路径(非特权)。 System.getProperty ("user.home") only returns me the admin user path. System.getProperty ("user.home") 只返回管理员用户路径。 Can anyone help me solve this problem?谁能帮我解决这个问题?

Thanks a lot非常感谢

Change "user.home" to "user.name" ."user.home"更改为"user.name" However, if you run the program as Administrator that is what it will return.但是,如果您以管理员身份运行该程序,它将返回。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM