Re: Deleting accounts and folders

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Jerold Schulman (Jerry_at_jsiinc.com)
Date: 06/18/04


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



Relevant Pages

  • Re: finding duplicated files
    ... duplicates and rems out the delete command for the first duplicate in each set. ... echo Purpose: Deletes identical files using multiple checksums from FSUM ... goto:EOF ...
    (microsoft.public.win2000.cmdprompt.admin)
  • Re: OT: help with a text file
    ... goto:EOF ... echo %line%>>outputfile.txt ... I'd also recommend VBScript. ...
    (sci.electronics.design)
  • Re: Network File Audit/Scanning
    ... echo Checking %1 ... if exist c:\Audited\%1.txt goto:eof ... you all PCs that have the file you're looking for. ...
    (microsoft.public.windows.file_system)
  • Re: Network File Audit/Scanning
    ... echo Checking %1 ... if exist c:\Audited\%1.txt goto:eof ... you all PCs that have the file you're looking for. ...
    (microsoft.public.windows.file_system)
  • Re: Searching Within a Text File
    ... Steve Seguis schrieb: ... > goto:EOF ... @echo off&setlocal EnableDelayedExpansion ...
    (microsoft.public.scripting.vbscript)