This can turn some administration tasks into very
short work.
Wacky Script Ideas
The point of scripting is that instead of using a canned application to perform
a certain task, you can easily and quickly throw together a script that
does exactly what you need. That said, you may need some inspiration to
get you cooking.
The following examples use many of the custom subroutines and functions
outlined earlier in this book, but for brevity and sanity, they won??™t be
repeated in the forthcoming snippets of code.
Quick and Dirty Backup Tool
The script in Example 9-2 starts by prompting you for the name of a folder
to back up and checks whether it exists. If not, it gives you an opportunity
to either type another folder name or exit. Once you??™ve entered a valid
folder name, the script creates a backup of the entire folder on a removable
drive (set with the TargetDrive variable), such as a USB memory key or flash
card.
Wacky Script Ideas | 547
Scripting and
Automation
This script uses several MsgBox prompts and, if used unaltered, will probably
irritate just about anybody. (Hint: think about who will be using the scripts
you write when you decide how much error checking and prompting is
appropriate.) However, it also shows part of the power of interactive scripting:
a little intelligent planning and error trapping can keep your scripts running
smoothly, interrupting you only when necessary. For instance, note the
use of the FolderExists function at the beginning of the script; rather than
risking encountering an error, the script checks for a potential problem (a
missing file) and then takes the necessary steps to resolve it.
Pages:
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762