Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- :: Purpose: Deletes old cached user profiles on computers listed in the names file
- :: Requirements: 1. Run this script with a network admin account
- :: 2. delprof.exe is required and may 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 the names file in the same directory as this script
- :: Author: vocatus on reddit.com/r/sysadmin
- :: History: 1.5c Commenting cleanup
- :: 1.5b Fixed hardcoded log entry line
- :: 1.5 Switched reading from names file to using the system name
- :: Added logging function
- :: 1.4 Updated menus and comments
- :: 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
- :: 1.1 Changed around menus, the first screen is now informational, the second is the "action" screen
- :: 1.0 Initial write
- :: Prep
- @echo off
- cls
- set VERSION=1.5b
- title Orbital Cached Profile Nuker v%VERSION%
- :::::::::::::::
- :: VARIABLES :: -- set these
- :::::::::::::::
- :: Set log info here, no trailing slash (\) on directory names
- set LOGPATH=%SystemDrive%\Logs
- set LOGFILE=%COMPUTERNAME%_OCPN.log
- :: Specify the name of the text file containing the list of systems you want to run against.
- :: This file must exist!
- set NAMES_FILE=names.txt
- :: Connection timeout in seconds
- set TIMEOUT=7
- :: Don't edit this variable
- set DAYS=%1
- :: Test for run-once
- if '%1'=='' set DAYS=60&& goto manual
- set DAYS=%1&& goto auto
- cls
- :: User notice
- :manual
- color 0c
- echo.
- echo *********************************************************
- echo * v%VERSION% *
- 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.
- echo The next screen will let you set the number of days.
- echo.
- pause
- color 07
- cls
- :: Ask user how many days old the profiles should be before getting nuked
- echo.
- 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 *********************************************************
- echo.
- set /p DAYS=Nuke profiles older than how many days? [%DAYS% recommended]:
- :: HIROSHIMA!
- :auto
- title Nuking profiles, please wait...
- cls
- echo.
- echo Nuking cached profiles older than %DAYS% days. Please wait for radiation to clear...
- echo.
- echo. > %LOGPATH%\%LOGFILE%
- FOR /F %%i in (%NAMES_FILE%) do (
- delprof /Q /I /C:\\%%i /D:%DAYS% >> %LOGPATH%\%LOGFILE%
- )
- del %NAMES_FILE%
- echo.
- echo Done nuking. Profiles older than %DAYS% days were obliterated.
- echo.
- pause
- title %USERNAME%
Add Comment
Please, Sign In to add comment