Remove Local Profiles Via Script

Reading Time: < 1 minute

If you wish to remove a selected number of local profiles via script but not all, for example remove all local profiles starting with 80 or 90 or pc etc, you can use the below script as a bat fileand run on system startup or shutdown via group policy.

Please note, deleting local profiles will also delete the my documents folder within the profile unless you have my documents folder redirection configured.

@echo off
c:
cd\documents and settings
for /f %%f IN (‘dir /b 10*; dir /b 11*; dir /b 12*;) DO rd /s /q %%f

Change the numbers 10, 11, 12 as required. The above script will delete local profiles starting with 10, 11 or 12.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.