DELPROF (XP/2003 Server Resource Kit - download)

Delete windows user profiles. Does not work with Windows 7 or later.

Syntax
      DELPROF [options days]

Key
   /Q      Quiet, no confirmation.

   /I      Ignore errors and continue deleting.

   /P      Prompts for confirmation before deleting each profile.

   /C:\\computer_name
           Delete profiles on a remote computer.

   /D:Number_of_days
           Only delete profiles that have been inactive for
           'X' Number of days (or greater)

   /R      Delete roaming profile cache only

Alternatives

List local profiles:

Get-CimInstance -ClassName Win32_UserProfile -Filter "Special=False AND Loaded=False" | Select SID,localpath

Delete a user profile on a remote machine with PowerShell [via adamtheautomator.com]:

PS C:\> Get-CimInstance -ComputerName 'workstation64' -Class Win32_UserProfile | Where-Object { $_.LocalPath.split('\')[-1] -eq 'User64' } | Remove-CimInstance

The LocalPath of the profile will normally end in the username but if a user account is renamed the path will not update and will retain the old name.

Helge Klein's Delprof2, Delprof2 is syntax compatible with the original Delprof by Microsoft but does have issues with UWP (Windows Store) apps on Windows 10.
To run Delprof2 on a remote PC (with PowerShell):

PS> Invoke-command -computername 'workstation64' -scriptblock {& "C:\utils\delprof2.exe" '/q'}

In the Windows 10 GUI right-click My Computer ➞ Properties ➞ Advanced System Settings ➞ User Profiles ➞ account ➞ Delete

“The best way to destroy the capitalist system is to debauch the currency” ~ John Keynes

Related commands

WMI/PowerShell script to delete user profiles - Idera.
Delprof2 - Delete Profiles Utility (Helge Klein).
DELTREE - Delete a folder and all subfolders.
RD - Delete folders or entire folder trees.


 
Copyright © 1999-2024 SS64.com
Some rights reserved