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 outlined earlier in this book, but for brevity and sanity, they won’t be repeated.
Quick Floppy Backup Tool
The script in Example 9-4 starts by prompting you for the name of a folder to back up and checks to see if it exists. If not, it gives you an opportunity either to type another folder name or exit. Once a valid folder name has been entered, the script creates a backup of the entire folder on your floppy drive.
Example 9-4. Quick Floppy Backup Tool
On Error Resume Next Accepted = False Do Until Accepted MyFolder = InputBox("Please enter the name of the folder _ you want to back up.") If Not FolderExists(MyFolder) Then Answer = MsgBox("The folder you typed doesn't exist. _ Try again?", 36, "") If Answer = 7 Then WScript.Quit Else Accepted = True End If Loop Answer = MsgBox("Please put a diskette in your floppy drive.", 33, "") If FolderSize(MyFolder) > DriveFreeSpace("a") Then MsgBox "The folder you specified won't fit on the floppy.", 16 WScript.Quit End If If FolderCreate("a:\Backup\") = False Then MsgBox "There was a problem writing to the diskette.", 16 WScript.Quit End If Call FolderCopy(MyFolder, "a:\Backup\") If Right(MyFolder, 1) <> "\" Then MyFolder = MyFolder ...
Get Windows Me Annoyances now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.