Linux-Noob Forums

Full Version: Automating the defrag process
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

Today I decided to use that defrag.vbs in my last tip to defrag the computers on my lan at the stroke of midnight each month.

Here is how to do it using simple batch scripting. There could be a simpler way but I just put this together and copy and pasted a few lines and boom I was done and never had to leave my seat.

 

[ADDDEFRAG.BAT]

 

mkdir \\computer\c$\scripts

copy C:\apps\scripts\defrag.vbs \\computer\c$\scripts\

AT \\computer 00:00 /INTERACTIVE /EVERY:1 c:\scripts\defrag.vbs

 

The first line makes a directory on the users computer called scripts.

The next line copies the defrag.vbs from my computer to the users newly created script folder.

The last line makes use of the AT command to schedule the defrag to run at midnight monthly.

 

In the batch file I just copied the 3 lines over and over until I had added all the computers I needed and edited the lines. Then I sat and executed it with a smile, watching it do all the work.