JSI Tip 8338. When you use DelPof.exe to remotely delete user profiles, Windows Installer data for the profile is NOT deleted?

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
DELPROF.EXE %1 %2 %3 %4 %5 %6
if \{%1\}==\{\} goto finish
set param=%1
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
goto :EOF
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 (
if "%OK%" EQU "Y" goto :EOF
@echo REG DELETE %fullkey% /F
REG DELETE %fullkey% /F

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.