Re: Deleting accounts and folders
From: Jerold Schulman (Jerry_at_jsiinc.com)
Date: 06/18/04
- Next message: Crazy Horse: "Re: Windows 2000 vs. XP Home Edition ?"
- Previous message: Peter Forster [MVP]: "Re: Max disk /partition size"
- In reply to: sherman: "Deleting accounts and folders"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 18 Jun 2004 07:41:14 -0400
On Thu, 17 Jun 2004 12:41:53 -0700, "sherman"
<anonymous@discussions.microsoft.com> wrote:
>
>
>is there a setup to where I can delete the account off of
>active directory as well as deleting the account's folder
>at the same time?
You could use the following batch:
@echo off
if {%1}=={} @echo Syntax: DelUser UserName&goto :EOF
setlocal
set user=%1
for /f "Tokens=2*" %%a in ('net user %user% /domain^|Findstr /i /L /C:"User
name" /C:"User profile" /C:"Home directory"') do (
REM The above 2 lines are 1 line
set type=%%a
set data=%%b
call :del
)
if /i "%user%" NEQ "%usr%" goto notfound
net user %user% /delete /domain
if exist "%home%" rd /s /q "%home%"
if exist "%profile%" rd /s /q "%profile%"
endlocal
goto :EOF
:notfound
@echo User %user% not found.
endlocal
goto :EOF
:del
if /i "%type%" EQU "name" set usr=%data%&goto :EOF
if /i "%type%" EQU "profile" set profile=%data%&goto :EOF
set home=%data%
Jerold Schulman
Windows: General MVP
JSI, Inc.
http://www.jsiinc.com
- Next message: Crazy Horse: "Re: Windows 2000 vs. XP Home Edition ?"
- Previous message: Peter Forster [MVP]: "Re: Max disk /partition size"
- In reply to: sherman: "Deleting accounts and folders"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|