Skip to content

Instantly share code, notes, and snippets.

@CalebGilliard
Forked from maciakl/profile-cleanup.cmd
Created February 12, 2024 19:46
Show Gist options
  • Save CalebGilliard/78ddc1229605f8db72ce0c0485099318 to your computer and use it in GitHub Desktop.
Save CalebGilliard/78ddc1229605f8db72ce0c0485099318 to your computer and use it in GitHub Desktop.
A script to delete user data for those occasions where you just want to nuke all user data without reimaging machine.
@echo off
REM use this file to run the powershell script bypassing the policy restrictions
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& '%~dpn0.ps1'"
pause
# Delete User Documents
(Remove-Item "$Env:userprofile\Music\*" -force -recurse) 2>$null
(Remove-Item "$Env:userprofile\Pictures\*" -force -recurse) 2>$null
(Remove-Item "$Env:userprofile\Downloads\*" -force -recurse) 2>$null
Remove-Item "$Env:userprofile\Favorites\*" -force -recurse 2>$null
Remove-Item "$Env:userprofile\Documents\*" -force -recurse 2>$null
# Delete Outlook PST Files
Remove-Item "$Env:appdata\Microsoft\Outlook\*" -force -recurse 2>$null
# Delete Cache and Temp Files
Remove-Item "$Env:userprofile\Appdata\Local\Microsoft\Windows\Caches\*" -force -recurse 2>$null
Remove-Item "$Env:userprofile\Appdata\Local\Microsoft\Windows\Temporary Internet Files\*" -force -recurse 2>$null
Remove-Item "$Env:userprofile\Appdata\Local\Temp\*" -force -recurse 2>$null
# Clean up IE Profile
#RunDll32 InetCpl.cpl,ClearMyTracksByProcess 1 # Clear IE History
#RunDll32 InetCpl.cpl,ClearMyTracksByProcess 2 # Clear IE Cookies
#RunDll32 InetCpl.cpl,ClearMyTracksByProcess 8 # Clear IE Temp Files
#RunDll32 InetCpl.cpl,ClearMyTracksByProcess 16 # Clear IE Form data
#RunDll32 InetCpl.cpl,ClearMyTracksByProcess 32 # Clear IE Saved Passwords
RunDll32 InetCpl.cpl,ClearMyTracksByProcess 255 # Clear IE Everything
# Delete Firefox and Chrome profiles
Remove-Item "$Env:appdata\Mozilla\Firefox\Profiles*" -force -recurse 2>$null
Remove-Item "$Env:userprofile\Appdata\Local\Google\Chrome\User Data\*" -force -recurse 2>$null
# Delete recent programs and documents from Start menu
Remove-Item "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist" -recurse 2>$null
# Delete Outlook profiles
Remove-Item "HKCU:\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Outlook" -recurse 2>$null
Remove-Item "HKCU:\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Zimbra" -recurse 2>$null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment