Automating Computer Maintenance

I have written several posts in the past regarding regular computer maintenance. Keeping a regular maintenance schedule is important if you would like to protect yourself against viruses and spyware, as well as maintaining the computer performance. My latest post title Regular Computer Maintenance provided a tutorial on performing some standard maintenance on your computer.

In addition to the information provided in that post, there is an automated way of virus and spyware scanning as well as defragging your hard drive, all without you having to worry about it in the future. This post explains how to accomplish this.

The Tools

Before we begin to automate the maintenance tasks it is important to first introduce the tools that will help us. We will be using a virus scanner, spyware scanner, and a defrag program. The tools I have chosen are all free, and can be run from the command line, or a DOS prompt.

The tools are:

Note:

The defrag program that is included with Windows XP can also be used, but the only problem is that you can only defrag one drive at a time. JKDefrag allows you to defrag all drives with one command.

If you are using the above tools, then download and install them. For the defrag progam, just extract it to a directory as it does not come with an install program. Remember where the tools are installed since you will need to know that information in the next sections. I will be using the tools above in the next few sections, but if you chose a different tool then you will need to substitute my tool for yours.

Automating Virus Scan

The first maintenance task that we will automate will be the virus scanning. We will be running this at least once a week to ensure that there are no viruses installed.

In the examples that follow, each of the files should only contain 2 lines of code. They may wrap in this page, but there should only be two lines in each file. To automate this task, use the following steps:

  1. Open up Windows Notepad by pressing Windows Key+R to open the Run dialog. Enter notepad in the box and press OK.
  2. In the blank Notepad window, type:
    @echo off

    “C:\Program Files\Grisoft\AVG7\avgscan.exe” /MEM /LOG c:

  3. Note:

    Subsitute the location of the virus scanner into the file if it is located in a different directory than is specified here.

  4. Click File->Save and specify a directory to save the file. Remember where you save the file as you will need to know this later.
  5. In the File name box enter vscan.bat.
  6. Beside Save as type, select All files.
  7. Click the Save button to save the file.

This file will execute the virus scanner without any interaction by a user. We will schedule this later in this post, but first we will continue to create two more files to automate the other processes.

Automating Spyware Scan

The steps required to automate the spyware scanner is very similar to the virus scanner. They are outline below.

  1. Open up Windows Notepad by pressing Windows Key+R to open the Run dialog. Enter notepad in the box and press OK.
  2. In the blank Notepad window, type:
    @echo off

    “C:\Program Files\Spybot – Search & Destroy\SpybotSD.exe” /autoupdate /autoimmunize /autocheck
    /autofix /autoclose

  3. The above command will also automatically update your definitions for the application as long as you have an active Internet connection.

    Note:

    Subsitute the location of the spyware scanner into the file if it is located in a different directory than is specified here.

  4. Click File->Save and specify a directory to save the file. Remember where you save the file as you will need to know this later.
  5. In the File name box enter spyscan.bat.
  6. Beside Save as type, select All files.
  7. Click the Save button to save the file.

Automating Hard Drive Defrag

Similar to automating the previous two tasks, the defrag program will run in a similar fashion:

  1. Open up Windows Notepad by pressing Windows Key+R to open the Run dialog. Enter notepad in the box and press OK.
  2. In the blank Notepad window, type:
    @echo off

    C:\Program Files\jkdefrag\jkdefragcmd.exe” -a 3 -d 2 -q -l “defrag.log” c:

  3. If you would like to defrag more than just the C drive, simply enter the other drive letters after “c:”.

    Note:

    Subsitute the location of the spyware scanner into the file if it is located in a different directory than is specified here.

  4. Click File->Save and specify a directory to save the file. Remember where you save the file as you will need to know this later.
  5. In the File name box enter defrag.bat.
  6. Beside Save as type, select All files.
  7. Click the Save button to save the file.

Now we have our three batch files that will execute the maintenance tasks for us. We could easily execute any of the batch files and they would perform their task; however, this post is about automating, so the next part will show how to do just that.

Schedule the Tasks

To schedule the tasks we will be using the standard task scheduler that is included with Windows. To schedule the tasks do the following:

  1. Click Start Menu->All Programs->Accessories->System Tools->Scheduled Tasks.
  2. In the scheduled tasks window, double-click the Add Scheduled Task icon, and then click Next to continue.
  3. In the next window click the Browse button and then navigate to the directory that contains your virus scanner file create in the Automating Virus Scan section.
  4. Click the file, and then click the Open to select it.
  5. You should now be prompted for a name. Enter Virus Scan and then select Weekly from the options list on the screen. Click Next to continue.
  6. The next screen is where you specify when the task should run. Enter a time and select the days you want the task to run. For me I selected 1:00 AM and Saturday as my schedule. Once you enter the time and day click Next to continue.
  7. The last step prompts you for a user ID and password. The user ID specified is your current log in ID. If that user ID has enough permissions to run the program, then just enter the password associated with your ID. Leave it blank if there is no password. Once you enter the user ID and password, click Next to continue.
  8. You should now see a summary of the task. Verify that the information is correct, and click Finish to save the task.

You have now scheduled your virus scanner to run at a specific time each week. Repeat the steps again for the spyware scan and the defrag program. You may want to specify a different time to run the next two tasks to prevent your computer from slowing when running them. Make sure you change the names of the new tasks to reflect what they are doing.

For me, the remaining tasks were scheduled as the following:

  • Spyware Scan – 4:00 AM Saturday
  • Defrag – 1:00 AM Sunday

Summary

This post explained how to schedule three of the important computer maintenance tasks that you need to perform. The three tasks will automatically execute once a week at a time when my computer is rarely in use so it won’t impact me when I’m using the computer.

Most virus and spyware scanning, and defrag applications include a built-in scheduler, but the difference is that the applications used in this post cost nothing to use and can easily be schedule through the Windows Task Scheduler.

Follow Me