Removing local users

  • Thread starter Thread starter Chris Hall
  • Start date Start date
C

Chris Hall

Greetings,

We've been using local users on about 100 PCs and are in the process on
moving to a Windows A.D. environment. Is there an easy way to delete users
from these workstations? Scripting, GPOs, etc? We're currently looking at a
piece of software--User Manager Pro--for this purpose, but would rather save
the dollars if possible. BTW, the PCs are w2k and xp.

Thanks,
Chris
 
Chris Hall said:
Greetings,

We've been using local users on about 100 PCs and are in the process on
moving to a Windows A.D. environment. Is there an easy way to delete users
from these workstations? Scripting, GPOs, etc? We're currently looking at a
piece of software--User Manager Pro--for this purpose, but would rather save
the dollars if possible. BTW, the PCs are w2k and xp.

Thanks,
Chris

You could run this batch file on each workstation:

@echo off
goto Start
--------------------------------------------------------------
Create a list of all users defined on this machine. Note that
the process will fail if there are user names with embedded
spaces.

17.6.2003 Fritz Lang
--------------------------------------------------------------

:Start
cd /d "%temp%"
net user | more +4 | find /i /v "successfully" >users.1

if exist users.2 del users.2
for /F "tokens=1" %%n in (users.1) do echo %%n>>users.2
for /F "tokens=2" %%n in (users.1) do echo %%n>>users.2
for /F "tokens=3" %%n in (users.1) do echo %%n>>users.2

type users.2 | sort > users.txt

for /F %%a in (users.txt) do if /i not %%a==Administrator (
echo net user %%a /del
echo rd /s /q "%allUsersProfile%\..\%%a"
)

Remove the words "echo" in the two lines towards the end
to activate the batch file.

You can use psexec.exe (www.sysinternals.com) if you wish
to run this script from a central location.
batc
 
Thanks, Pegasus!

Chris

Pegasus (MVP) said:
at

You could run this batch file on each workstation:

@echo off
goto Start
--------------------------------------------------------------
Create a list of all users defined on this machine. Note that
the process will fail if there are user names with embedded
spaces.

17.6.2003 Fritz Lang
--------------------------------------------------------------

:Start
cd /d "%temp%"
net user | more +4 | find /i /v "successfully" >users.1

if exist users.2 del users.2
for /F "tokens=1" %%n in (users.1) do echo %%n>>users.2
for /F "tokens=2" %%n in (users.1) do echo %%n>>users.2
for /F "tokens=3" %%n in (users.1) do echo %%n>>users.2

type users.2 | sort > users.txt

for /F %%a in (users.txt) do if /i not %%a==Administrator (
echo net user %%a /del
echo rd /s /q "%allUsersProfile%\..\%%a"
)

Remove the words "echo" in the two lines towards the end
to activate the batch file.

You can use psexec.exe (www.sysinternals.com) if you wish
to run this script from a central location.
batc
 
Back
Top