Software // Enterprise Applications
Commentary
10/23/2003
11:18 PM
Fred Langa
Fred Langa
Commentary
Connect Directly
RSS
E-Mail
50%
50%

Langa Letter: Make Windows XP Self-Maintaining

Fred Langa explains how to automate Windows XP tools and tasks that normally require manual intervention.

Automated, Unattended Defragmentation
The normal, manual way to run Defrag is to click to Start/Control Panel/Performance and then select "Rearrange items on your hard disk to make programs run faster." All those clicks, and all that verbiage, simply starts the Defrag.Exe program (usually located in the Windows/System32 folder). When you run Defrag this way, it comes up with a graphical front end that requires still more pointing and clicking to make anything actually happen. So, this approach is useless for automated defrags when no one will be there to point and click as needed.

You get the same results if you search for "Defrag" in XP's help file: The primary search results ("Using Disk Defragmenter" and "Disk Defragmenter") offer links to the graphical, manual version of Defrag.

But Defrag can run just fine with no graphical front end at all and that's the key to using it in an automated fashion. To use Defrag (and other, similar system tools) this way, you launch the tool via a command line plus any "switches" you want to use to modify the file's behavior. (If you're not familiar with these terms, don't worry:)

To see how simple this really is, open an empty XP "command window": Click to Start/Run and then type the word "command" (without the quotes) in the Run line, and click OK. A command window, usually a mostly black box, will open. There'll be a blinking prompt at the end of a line of text. The text indicates your location within your hard drive's folder structure; and the blinking prompt shows you where anything you type will be entered. You can type any valid XP command there and XP will perform the action. You also can launch programs by typing the name of the tool, and that's what we're interested in here.

Almost all command-line tools offer simple, built-in help that you access simply by adding " /?" or " -?" (without the quotes) to whatever command or tool you're trying to learn about. For example, we're interested in Defrag here, so type DEFRAG /? (note the blank space after DEFRAG) and hit enter. This calls up simple help about Defrag in the form of a list of available Defrag options, and a template showing you how to enter Defrag commands in the correct format and order.

Using the Defrag help text as a guide, you can see that manually triggering Defrag is simplicity itself: The command "DEFRAG C:" (without the quotes) would tell Defrag to work on your C: volume or drive, for example. "DEFRAG D:" would tell Defrag to work on the D: drive. "DEFRAG C: -a" would tell Defrag to analyze how much your C: drive is fragmented, but not to actually perform a defragmentation. And so on.

In fact, if you type DEFRAG C: now, and hit enter, Defrag will run. But don't do it yet, because we're looking to automate the process, not to run it manually.

Previous
2 of 5
Next
Comment  | 
Print  | 
More Insights
Building A Mobile Business Mindset
Building A Mobile Business Mindset
Among 688 respondents, 46% have deployed mobile apps, with an additional 24% planning to in the next year. Soon all apps will look like mobile apps – and it's past time for those with no plans to get cracking.
Register for InformationWeek Newsletters
White Papers
Current Issue
InformationWeek Tech Digest September 18, 2014
Enterprise social network success starts and ends with integration. Here's how to finally make collaboration click.
Flash Poll
Video
Slideshows
Twitter Feed
InformationWeek Radio
Sponsored Live Streaming Video
Everything You've Been Told About Mobility Is Wrong
Attend this video symposium with Sean Wisdom, Global Director of Mobility Solutions, and learn about how you can harness powerful new products to mobilize your business potential.