Can I folder associated to a user account in active
directory be deleted at the same time I delete the
account? If so, How can I do this?
Yes.
Assuming the user's home folder and profile are on a server, you could run:
deluser username[,username2,username3,....]
where deluser.bat contains:
@echo off
if {%1}=={} @echo Syntax: deluser username[,username2,username3,....]&goto :EOF
setlocal
:loop
if {%1}=={} endlocal&goto :EOF
set user=%1
shift
set fnd=N
for /f "Skip=2 Tokens=1,2*" %%a in ('net user %user% /domain') do (
call :find %%a %%b "%%c"
)
goto loop
:find
if "%fnd%" EQU "Y" goto find1
if /i "%1" NEQ "User" goto :EOF
if /i "%2" NEQ "name" goto :EOF
set fnd=Y
net user %user% /domain /delete
goto :EOF
:find1
if /i "%1" NEQ "User" goto :find2
if /i "%2" NEQ "profile" goto :EOF
if exist %3 rd /q /s %3
goto :EOF
:find2
if /i "%1" NEQ "Home" goto :find2
if /i "%2" NEQ "directory" goto :EOF
if exist %3 rd /q /s %3
NOTE: I didn't test this.
Jerold Schulman
Windows: General MVP
JSI, Inc.
http://www.jsiinc.com