Word Hacks [Electronic resources]

Andrew Savikas

نسخه متنی -صفحه : 162/ 116
نمايش فراداده

Hack 81 Use Word as a Windows Backup Utility

This hack introduces a freeware, hackable Word template for building system backups.

Backups usually end up on tomorrow's to-do list, but now you can create quick and easy backups with a freeware template, a great example of how you can hack Word into a serious system administration tool.

You can download the template used in this hack from http://www.mousetrax.com/Downloadsl#backup. The download includes two files:

WordBackup.dot

ConfigWordBackup.cfg

To test-drive the template, create a folder on your system called C:\Backup. Put both files in the new folder.

By default, the template creates a backup of each of the following system folders:

Currently logged-on user's My Documents folder

Currently logged-on user's Templates folder

Currently logged-on user's Internet Explorer Favorites folder

Windows Fonts folder

Currently logged-on user's Desktop folder

The backups are created in the folder in which the WordBackup.dot template is located; here, it's C:\Backup.

9.3.1 Running the Hack

To begin the backup, just double-click the WordBackup.dot file icon. A new, blank Word document opens, and the backup begins.

The status bar notes the backup's progress. When the backup finishes, it launches Notepad and opens the LogWordBackup.log file created by the template, as shown in Figure 9-2.

Figure 9-2. The log file created by the WordBackup.dot template

Depending on the size of your hard drive and the speed of your processor, the backup may take several minutes or more. Once it finishes, the C:\Backup folder will contain backup copies of all those important system folders.

The next time you need a backup, just double-click the template icon again. Subsequent backups are much faster, since the template backs up only files that have changed since the last backup (known as an incremental backup).

9.3.2 Hacking the Hack

If you've got important files in folders besides the standard system ones, or files on a network drive that should also be backed up, you can change how the WordBackup.dot template works by adjusting the settings in the ConfigWordBackup.cfg file, which is just a plain-text configuration file [Hack #67] .

To edit the ConfigWordBackup.cfg file, open it in a standard text editor, such as Notepad. The file contains two sections: Parameters and Folders.

9.3.2.1 The Parameters section

Here you can use the debug key to specify how verbose of a log file you're looking for. A value of 0 records only the start and stop time, and a value of 4 gives you full reporting. The ConfigWordBackup.cfg file includes details on each level.

If you want the backup in a different folder, use the altpath key. For example, to put the backup files in a folder named C:\Foo\Backup, change the altpath line to read as follows:

altpath=C:\Foo\Backup

9.3.2.2 The Folders section

In this section, you can have the template ignore one or more of the system folders that it backs up by default. The settings are already in the file but are commented out. To activate any of them, remove the semicolon at the start of the line. For example, if you want the template to ignore the Fonts folder, remove the semicolon from the ;NoFonts line, so it reads as follows:

NoFonts

Again, the ConfigWordBackup.cfg file includes further details.

If you want to back up folders besides the system folders, include each folder on its own line in the Folders section, as follows:

C:\Evil\Master Plans\World Domination

The template can also back up files on a network drive using standard Universal Naming Convention (UNC) notation, as in the following:

\\hal9000\flightplans\archive

Make sure the folders you specify in the ConfigWordBackup.cfg file actually exist on your system, or you'll encounter errors during the backup.

Greg Chapman