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 "%%nlocal settingstempor~1"
for /f %%n in ('dir /a:d /b') do del /s /q "%%nlocal settingstemp"
del /s /q "%systemroot%offline web pages"
del /s /q "%systemroot%pchealtherrorrep"
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%system32jkdefragcmd.exe copy \serverpublictoolsjkdefragcmd.exe %systemroot%system32
xcopy /s/e/c/d/y \serverpublictoolscleantemp.bat %systemroot%system32
if not exist %systemroot%tasksCleanTemp.job %systemroot%system32schtasks.exe /create /tn "CleanTemp" /tr %systemroot%system32CleanTemp.bat /sc weekly /d WED /st 17:15:00 /ru domainuser /rp [password]
if not exist %systemroot%tasksAutoDefrag.job %systemroot%system32schtasks.exe /create /tn "AutoDefrag" /tr %systemroot%system32JkDefragcmd.exe /sc weekly /d WED /st 17:30:00 /ru domainuser /rp [password]

yep… lets see how that works.

Did you like this? Share it:
This entry was posted in Tips and tricks and tagged , , , . Bookmark the permalink.

Leave a Reply

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