for /f %%a in (c:\list.txt) do psexec -s -d \\%%a defrag c: && shutdown -s -f
Save this as a .bat file. Download psexec from sysinternals
Create a directory on your desktop, put the extracted psexec.exe and you .bat file in this directory. Create a list of machine names you want to defrag, an AD dsquery output or manual list creation. Name this file list.txt. Double click .bat file or add it to scheduled tasks for later in evening.
Here is the VB code to defrag
Now to make it run as admin or system
is how to do this, push out its install through GP, then use it to create a job file, and run the job file as a shutdown script
You cannot set a defragmentation command using the group policy service of the Windows Operating System. You can only defrag a networked client by creating a software with the codes capable of defragging network hard drives.