Skip to content

Instantly share code, notes, and snippets.

@013
Created July 24, 2013 15:05
Show Gist options
  • Save 013/6071416 to your computer and use it in GitHub Desktop.
Save 013/6071416 to your computer and use it in GitHub Desktop.
Remove a profile from Windows registry
@echo off
set username=
AT > NUL
IF %ERRORLEVEL% EQU 0 (
goto start
) ELSE (
ECHO This scripts needs to be run with Administrator privileges
goto end
)
:start
if "%username%"=="" (
set /p username="Enter Username to remove: " %=%
)
for /f "tokens=*" %%a in ('reg QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList" /f "%username%" /s') do set corruptpath=%%a && goto found
:found
if "%corruptpath:~0,1%"=="E" (echo No profile found&& goto end)
echo Removing profile
reg DELETE "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\%corruptpath%"
:end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment