0

Possible Duplicate:
Using Java, How can I get a list of all local users on a windows machine

Any ideas on how to get all the users on a Windows PC using java? For example, I have a admin account named "Admin" and a non admin account named "User". Any way I can get these values?

Community
  • 1
  • 1
user489041
  • 27,916
  • 55
  • 135
  • 204
  • No, you can't get hold of that information without executing native commands (might even be impossible in that case) – Kaj May 24 '11 at 13:55

1 Answers1

0

Untested, but you could try getting it from the Windows "users" folder:

List<String> windowsUsers = new ArrayList<String>();
for (File userDirectory : new File("C:/Users").listFiles())
{
    windowsUsers.add(userDirectory);
}
Amy B
  • 17,874
  • 12
  • 64
  • 83
  • +1 cool this is a possible way but then it is going to vary from win version to win version. One note here: I think you meant `userDirectory.getName()` instead of `userDirectory`. – Boro May 24 '11 at 14:02
  • 1
    Users Directories can have other directories also.So I think this will not work always. – Naresh May 24 '11 at 14:04