When you type Delprof.exe /?, it
displays:
This utility deletes Windows NT, Windows 2000, Windows XP and Windows Server 2003 family user profiles.
usage: DELPROF [/Q] [/I] [/P] [/R] [/C:\\<computername>] [/D:<days>]
/Q Quiet, no confirmation.
/I Ignore errors and continue deleting.
/P Prompts for confirmation before deleting each profile.
/R Delete roaming profile cache only
/C Remote computer name.
When you use this tool to remotely delete unused profiles, the Windows Installer registry data for the profile is
NOT deleted.
NOTE: When you run Delprof.exe locally, Windows Installer registry data for the deleted profiles is deleted.
This behavior occurs because the Windows Installer tool DOES NOT operate on remote computers.
To workaround this behavior, I have scripted DelProfR.bat to run Delprof.exe and to delete any
Windows Installer data if you run it remotely.
The syntax for using DelProfR.bat is the same as for running DelProf.exe:
DelProfR [/Q] [/I] [/P] [/R] [/C:\\<computername>] [/D:<days>]
DelProfR.bat contains:
@echo off
setlocal
DELPROF.EXE %1 %2 %3 %4 %5 %6
:loop
if {%1}=={} goto finish
set param=%1
shift
if /i {%param:~0,3%} NEQ {/C:} goto loop
if /i {%param:~3%} EQU {%ComputerName%} goto finish
set key1=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData
set qry1=reg query "%param:~3%\%key1%"
set fnd1=findstr /L /I /B /C:"HKEY_"
set key2=HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
set qry2=reg query "%param:~3%\%key2%"
set fnd2=findstr /L /I /B /C:"HKEY_"
For /f "Tokens=*" %%p in ('%qry1% ^|%fnd1%') do (
set fullkey=%%p
call :chksid
)
:finish
endlocal
goto :EOF
:chksid
set OK=N
set sidkey=%fullkey:~80%
if "%sidkey%" EQU "" goto :EOF
if "%sidkey:~10,1%" EQU "" goto :EOF
set work1=%sidkey%#
set work2=%work1:-500#=%
if "%work1%" NEQ "%work2%" goto :EOF
for /f "Tokens=*" %%a in ('%qry2% ^|%fnd2%^|findstr /L /I /C:"%sidkey%"') do (
SET OK=Y
)
if "%OK%" EQU "Y" goto :EOF
@echo REG DELETE %fullkey% /F
REG DELETE %fullkey% /F