Delete workstation profiles through Group Policy
Closed     Case # 10037     Affiliated Job:  New Trier Township District 2031
Opened:  Wednesday, February 3, 2010     Closed:  Wednesday, February 3, 2010
Total Hit Count:  6820     Last Hit:  Thursday, July 20, 2017 10:42:25 AM
Unique Hit Count:  2419     Last Unique Hit:  Thursday, July 20, 2017 1:48:40 AM
Case Type(s):  Development, Server
Case Notes(s):  All cases are posted for review purposes only. Any implementations should be performed at your own risk.

Problem:
Being a school district, we'll have some labs that incur several hundred students on a workstation throughout a day. The sheer number of profiles that can result over time in some cases can consume the disk space on the workstation.

Resolution:
We decided to deploy a routine that would delete the student profiles on shutdown of the workstation. To deploy, simply add the batch file to a Group Policy's Computer Shutdown Script - initiating the DelTreeProfiles.bat file. Make sure to adjust the appropriate settings for your environment. In our case below, all student accounts begin with "20" therefore, we can filter out the process to only delete student profiles by using wildcards.

An alternative is to use the "delprof.exe," however we have found in some cases this will take longer than the solution below. The code to institute the "delprof.exe" is included but REM'd out. If you decide to try this route, you will also need this file in the Group Policy's Computer Shutdown Script path.
-   DelTreeProfiles.bat
   o   @ECHO OFF
   o   
   o   @For /F "tokens=1,2 delims= " %%A in ('Date /t') do @(
   o   Set Part01=%%A
   o   Set Part02=%%B
   o   )
   o   
   o   @For /F "tokens=1,2,3 delims=/ " %%C in ('ECHO %Part02%') do @(
   o   Set Day=%%D
   o   Set Month=%%C
   o   Set Year=%%E
   o   Set DateOnly=%%E%%C%%D
   o   )
   o   
   o   For /F "tokens=1,2,3,4 delims=/ " %%A in ('Date /t') do @(
   o   Set Part01=%%A
   o   Set Part02=%%B
   o   Set Part03=%%C
   o   Set Part04=%%D
   o   Set DateOnly=%%D%%B%%C
   o   )
   o   
   o   ECHO Deleting Profiles Beginning with 20*...
   o   @ECHO OOOOO------ >> C:\delproflog.log
   o   
   o   @ECHO Processing "deltreeprofiles.bat" %DATE% %TIME% >> C:\delproflog.log
   o   For /D %%i in ("C:\DOCUME~1\20*") do rmdir %%i /S /Q >> C:\delproflog.log
   o   @ECHO Processing "deltreeprofiles.bat" %DATE% %TIME% >> C:\delproflog.log
   o   
   o   REM @ECHO Processing "delprof.exe" %DATE% %TIME% >> C:\delproflog.log
   o   REM \\somedomain.com\SysVol\nths.net\Policies\{GUID of Group Policy}\Machine\Scripts\Shutdown\delprof.exe /Q /I >> C:\delproflog.log
   o   REM @ECHO Processing "delprof.exe" %DATE% %TIME% >> C:\delproflog.log
   o   
   o   @ECHO OOOOO------ >> C:\delproflog.log
   o   ECHO Completed Deletion of Profiles...
-   Optional: delprof.exe
   o   Download: http://www.microsoft.com/downloads/details.aspx?familyid=901A9B95-6063-4462-8150-360394E98E1E&displaylang=en



Profile IMG: Footer Left Profile IMG: Footer Right