Hello all,

I have a question. I've been using a batch file to delete users from our computer lab here in campus. That batch file worked beautifully for Win 7, but not sure for win 8.1. We've been having problems with the accounts either not loading correctly, being corrupted, black screens, not getting the GPO. So I am not sure if the delete script is causing any issues.

Below is the batch file:

@echo on
SET rootKey=HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList


FOR /F "DELIMS=" %%i in ('DIR "C:\USERS" /B /AD') DO CALL :remove_old_profiles "%%i"
GOTO :eof


SET dirName=%~1

IF /I "%dirName%" EQU "Default" GOTO:eof
IF /I "%dirName%" EQU "Administrator" GOTO:eof
IF /I "%dirName%" EQU "administrator.CLCSEC4-134569" GOTO:eof
IF /I "%dirName%" EQU "Default User" GOTO:eof
IF /I "%dirName%" EQU "Public" GOTO:eof
IF /I "%dirName%" EQU "All Users" GOTO:eof
IF /I "%dirName%" EQU "%USERNAME%" (
ECHO Hey! You can't delete yourself, Mr. or Ms. %USERNAME%.
@ECHO Removing Profile List Sub Key...
FOR /F "DELIMS=" %%a IN ('REG QUERY "%rootKey%" /s /d /f C:\users\%dirName%') DO REG DELETE "%%a" /f
@ECHO Removing C:\Users\%dirName%...
RD /s /q "C:\USERS\%dirName%"
RD /s /q "C:\USERS\%dirName%"
GOTO :eof
@echo on

Any thoughts? I've been reading that there are differences between win 7 & win 8.1 when deleting users but haven't been able to find a solid answer.

All help will be greatly appreciated.

Thank you.