Novell Home

Autodefrag Multiple Computers at Night

Novell Cool Solutions: Tip
By Denys Plamondon

Digg This - Slashdot This

Posted: 15 Mar 2006
 

Do you ever wish you could autodefrag multiple computers at night while using Windows Scheduling? On the surface it seems it would be a very simple task, and provided your environment is setup correctly, it is easy. First of all, your target workstations must be registered. Second of all you must have a Wake On Lan policy. Third the ZENworks agents must be installed and running on the client.

First things first. We need to create a scheduled task on every XP computer on which you plan to run the defrag. So I created a ZENworks App that would call the schtasks.exe and put in the proper parameters to create the scheduled task. Proper parameters consist of:

  • Administrator Username
  • Administrator Password
  • Schedule of the task
  • Name of the Task
  • Time to run
  • What you want to run

Then I needed a batch file to actually run the defrag and shutdown the computer afterwards. This is what the scheduled task calls (aedfrg.bat ). Now we have a scheduled task that has the computer start a batch file which calls the defrag utility, then defrags the computer and shuts it down when it's finished.

With the computer ready to defrag automatically every night at 4:23AM (see below example) we have to make sure the computer is on so this can happen. I do this by creating a Wake On Lan policy under the server's policy package. This policy wakes up the target group every morning at 4:00AM. One more thing, if you are afraid that you will not have enough time to run the defrag before the users come in for work, set it up for Friday to run over the weekend. Once the fragmentation level goes down, it takes very little time to complete the defrag.

Example

ZENworks App Object

Path to file:

Either copy the schtasks.exe to somewhere on your network or call it directly from the workstation. I copied to the network.

Parameters:

/create /ru administrator /rp ?YOURPASSWORD? /sc daily /tn aedfrg /st 04:23:00 /tr c:\aedfrg.bat

I have also checked the Run Application Once (if you make a change to the batch file, just change the version of the NAL object).

I run it as Unsecure System User, and hidden.

Then under Distribution Options at Application Files, I set it to copy the batch file from the network to the root of the user's C Drive, and only copy if the file is newer.

Batch File (aedfrg.bat )

defrag c: -f
shutdown -s -t 15 -c "Defrag Complete Shutting Down"

If you have any questions you may contact Denys at plamondond@ae.ca

Other Suggestions

Shaun Pond

This could be useful if you feel the need to defrag your machines frequently, but there are some things to be aware of:

Firstly, you need to be know that if you're running on XP, you'll probably need SP2, or you'll need to use a 3rd-party alternative to shutdown.exe, like PSHUTDOWN.EXE.

Secondly, the method described in this tip should work, but it's possible to perform the same function without the need for an application object or a 3rd-party tool. ZENworks provides the ability to add to the workstation scheduler (installed as part of the |ZENworks agent), and you can create a scheduled action that runs both of these items in a workstation policy:


Note that I have the box "run items in order listed" checked, to ensure they run sequentially.

Set the schedule to run when you'd like it to take place, and set the impersonation to "system".


Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions. www.webwiseone.com

© 2014 Novell