Display a list of users on the local machine

Any pc / Any model
May 3, 2009 at 06:38:28
Specs: Windows XP and Vista, 4 Gigabytes
Easy Question:
Is there a way to display a list of non currently active user profile names on the local machine? (By non currently active, I mean to display a list of all of the profile names leaving out the one I am running the batch file from and all of the system profiles like the default or all users profile.)
1. There are 5 profiles on a Windows XP or Vista Computer. (ie. Tina, Tony, Wayne, Owner, Thomas).
2. Currently using and running the batch file from Owner.
3. Currently logged in are also the profiles Tina and Tony. (We are in switch user mode using Owner)

I would like to capture and store in multiple separate variables that Tina, Tony, Wayne and Thomas are also profiles on the computer. I would also like to capture if the computer adds any profiles later on in the future such as Randy.

Is there a way to do this? I have been searching all over the place for a command and I cannot find one.

I know that for XP, I can probably look into the documents and settings folder, get a dir listing and then subtract out all of the default names and the currently logged in name however I was hoping for something more simple.

Any thoughts?



See More: Display a list of users on the local machine

Report •

May 3, 2009 at 17:06:31
I found this on experts exchange. I figure I can modify this to fit my needs. I was just hoping there was an easier way then listing everything and then subtracting but I believe this will work. I modified this a little for Vista. The one I found was for XP.

@echo off
for /f "tokens=*" %%a in ('dir c:\users\ /b /ad') do call :process "%%a"
goto :eof

if [%1]==["Administrator"] goto :eof
if [%1]==["All Users"] goto :eof
if [%1]==["Default User"] goto :eof
if [%1]==["LocalService"] goto :eof
if [%1]==["NetworkService"] goto :eof


Report •
Related Solutions

Ask Question