my group policy defrag and optimize solution

i became aware of a shituation at work where users PC's were running like, well shit, after a coworker started inquiring about budgeting PC upgrades. The thought of upgrading 40 PCs that already had 2.7GHz P4's and 512MB of ram which are solely used for SAP and office became troubling, as there is absolutely no reason for such an upgrade. Upon further inspection, i found those who were complaining has *severe* fragmentation on their filesystems. Furthermore, since i locked the domain down, these users could not manually defragment their hard drives, and i refuse to walk about to each PC for this kinda crap. so… was time to think.

first, i found a disk defragment and optimization tool usable from the command line, called jkDefrag, available here. I extracted the jkdefragcmd.exe file, and stored on a server.

next i created a batch file for cleaning up files i deem useless, because why waste time defragmenting them, right? that was simply:

cd /d "c:\documents and settings"
for /f %%n in ('dir /a:d /b') do del /s /q "%%n\local settings\tempor~1"
for /f %%n in ('dir /a:d /b') do del /s /q "%%n\local settings\temp"
del /s /q "%systemroot%\offline web pages"
del /s /q "%systemroot%\pchealth\errorrep"
del /s /q "%systemroot%\downloaded installations"
del /s /q "%systemroot%\downloaded program files"

next up, the logon script for the OU my domain pc's reside on, which copies the defrag utility, and batch file above, then schedules them to run:

if not exist %systemroot%\system32\jkdefragcmd.exe copy \\server\public\tools\jkdefragcmd.exe %systemroot%\system32
xcopy /s/e/c/d/y \\server\public\tools\cleantemp.bat %systemroot%\system32
if not exist %systemroot%\tasks\CleanTemp.job %systemroot%\system32\schtasks.exe /create /tn "CleanTemp" /tr %systemroot%\system32\CleanTemp.bat /sc weekly /d WED /st 17:15:00 /ru domain\user /rp [password]
if not exist %systemroot%\tasks\AutoDefrag.job %systemroot%\system32\schtasks.exe /create /tn "AutoDefrag" /tr %systemroot%\system32\JkDefragcmd.exe /sc weekly /d WED /st 17:30:00 /ru domain\user /rp [password]

yep… lets see how that works.

Did you like this? Share it:
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

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