Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Script: Mass Windows old cached profile cleanup by hgate73
Posted: 17 Apr 10

If you are in a highly transient environment like I am, you have hundreds of users logging into workstations they'll probably never use again. This script uses delprof.exe from Microsoft to crawl through the network and delete old cached profiles from the computers, potentially freeing up GIGS of space. You can set the number of days to anything you want. The script reads computer names from the "names.txt" file, one per line.

Put in a bat file.


:: Author:          hgate73 at gmail or yahoo
:: Purpose:         Deletes old cached user profiles
:: Requirements:    1. Run this script with network admin privileges
::                  2. delprof.exe from Microsoft must be in any of these locations:
::                      a) the directory you run this script from
::                      b) in the PATH variable
::                      c) c:\windows\system32\
::                  3. Put the names of your computers, one per line, in a file called "names.txt" in the same directory as this script
:: Version:         1.3 Updated to allow for passing the number of days as an argument
::                  1.2 Changed script to use a FOR loop to read a list of pc names from a file instead of hard-coding them
:: History:         1.1 Changed around menus, the first screen is now informational, the second is the "action" screen
::                  1.0 Initial write

:: Prep
@echo off
title Orbital Cached Profile Nuker
set VERSION=1.3
set NAMES_FILE=names.txt
set DAYS=%1
if '%DAYS%'=='' goto manual
        goto auto

:: User notice
color 0c
echo  *********************************************************
echo  *                                                       *
echo  *         ORBITAL CACHED PROFILE NUKER (OCPN)           *
echo  * ----------------------------------------------------- *
echo  * Nuke them from orbit. It's the only way to be sure.   *
echo  *                                                       *
echo  * Windows 2000/XP caches user profiles when you login.  *
echo  * Over time these use up a lot of space. Annoying.      *
echo  *                                                       *
echo  * This script deletes those old profiles by using       *
echo  * "delprof.exe" from Microsoft.                         *
echo  *                                                       *
echo  *********************************************************
echo  The next screen will let you set the number of days.
color 07

:: Ask user how many days old the profiles should be before getting nuked
echo  *********************************************************
echo  *                                                       *
echo  *                  IT'S NUKING TIME                     *
echo  * ----------------------------------------------------- *
echo  *                                                       *
echo  * RULES for a safe and happy nuking:                    *
echo  *                                                       *
echo  * 1. Run this script with NETWORK ADMIN rights. Local   *
echo  *    admin rights won't work.                           *
echo  * 2. Run this script from the desktop, NOT a network    *
echo  *    path.                                              *
echo  * 3. "delprof.exe" must be in the same directory as     *
echo  *    this script. If you don't have it, Google and      *
echo  *    download it. (system32 is also okay)               *
echo  *                                                       *
echo  * After you enter the number of days and hit "enter"    *
echo  * the script will begin nuking!                         *
echo  *                                                       *
echo  *********************************************************
set /p DAYS=Nuke profiles older than how many days? (21 recommended):

title Nuking profiles, please wait...
echo Nuking cached profiles older than %DAYS% days. Please wait for radiation to clear...

FOR /F %%i in (%NAMES_FILE%) do delprof /Q /I /C:\\%%i /D:%DAYS%

echo Done nuking. Profiles older than %DAYS% days were obliterated.
title %USERNAME%

Back to Microsoft: Windows FAQ Index
Back to Microsoft: Windows Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close