Langa Letter: Solving Automatic Maintenance Problems

Fred Langa explains how to address problems with Windows XP automation, looking at XP's self-maintenance tools and techniques.
Borrowing The Wizard's Output For Your Own Scripts
All the above actually created an enormous, hidden command line, using whatever options you selected. That command line was then automatically entered into Task Scheduler to create a standalone Backup task. But we didn't go through all this just to create a standalone task. Rather, we did this so we could borrow the command line for your own scripts and batch files. Here's how: Click to Control Panel/Performance and Maintenance/Scheduled Tasks. When Task Scheduler opens, you'll see your new Backup job listed there, under whatever name you gave it. Right click on the job and select Properties.

The command line is listed in the "Run" box of the Task dialog. Copy and paste the entire command line to Notepad or a similar plain-text editor. The line will be huge and will look something like the below, but all in one long, unwrapped/unbroken line:

C:\WINDOWS\system32\ntbackup.exe backup "@C:\Documents and Settings\[username]\Local
Settings\Application Data\Microsoft\Windows NT\NTBackup\data\[backupjobname].bks" /n
"[backupfilename].bkf created 11/17/2003 at 11:52 AM" /d "Set created 11/17/2003 at 11:52 AM"
/v:no /r:no /rs:no /hc:off /m normal /j "[backupsetname]" /l:s /f "[backupfilepathandname].bkf"

Believe it or not, that entire paragraph above is a single command line. That's why we used the Wizard to generate it--it's much easier than trying to write so complex a command by hand.

Because you'll be using this command line to schedule backups to run as part of a complete maintenance operation along with other tools, you won't want to leave the standalone, Wizard-generated task active. So, before you close the Backup dialog in Scheduled Tasks, uncheck the "enabled" box, then click OK. Thus disabled, the task won't run on its own, but the disabled task will remain stored in the Task Scheduler, so you can go back and reuse its command line later, if you wish, without having to re-create it from scratch.

You can now paste Backup's complex command line into your own scripts and batch files, such as the examples shown in "Make Windows XP Self-Maintaining." That way, whatever other maintenance tasks you place in front of the Backup command will normally run to completion before Backup starts, and any tasks you add after the Backup command will normally wait until Backup has finished before executing. In this way, you get all the power of a complex, Wizard-generated command line, but smoothly integrated into your own preferred maintenance sequence.

Tweaks And Polishes
More on automated backups, including automatic compression of the backup files and automatic generation of unique file names:

How do you automate your maintenance tasks? How do you work around the limitations of "Wizard" based tools? How do you overcome the problems of sending extremely complex commands in scripts and batch files? Join in the discussion!

We invite you to check out Fred Langa's columns in InformationWeek's Windows Tech Center, also featuring exclusive Microsoft coverage by InformationWeek's reporting team.

To discuss this column with other readers, please visit Fred Langa's forum on the Listening Post.

To find out more about Fred Langa, please visit his page on the Listening Post.