CASE HISTORY # 8 - Conclusion by the Disk Doctor -------------------------------------------- Copyright (C) 1987, the Disk Doctor. First published in the Rochester (PC)^3 News: Picture City PC Programming Club PO BOX 20342 Rochester, NY 14602 The Disk Doctor may be contacted at this address, or via CIS [73147,414]. This material may be reproduced for internal use by other not-for-profit groups, provided this copyright notice is included. ---------------------------------------------- [In the last issue, the Disk Doctor was helping X., who accidentally formatted his hard disk.] 2:55pm It was X's boss, Mr. Y. "I just heard how you restored X's files. We got back just about all the super important files. I guess we're fortunate to have someone here with your training. Thank you for helping us out there." "You're welcome. I am always happy to be of service." "X. had a lot of important corporate records on his computer. When he accidently formatted his hard disk, he could have lost it all." "Don't be too hard on him. It was a honest mistake. He went to format a floppy disk, typed the command `FORMAT', and simply forgot to add the drive letter 'A:'. When he read the warning message and saw he was about to format the wrong drive, he tried to get out of it by pressing the ESC key. Unfortunately, only Break will abort that operation." I continued, "If you want to fault him for anything, get on his case to start making frequent backups. You know what I always say, 'If you can't afford to lose it, ...' ". "'...you can't afford NOT to back it up!'" Mr. Y finished my line. "Even so, I just don't know how anyone could be so careless." "It's an easy mistake to make. After a while all of us get sloppy. You get in the habit of pressing Enter, and ignore the warning message. Why, I came close to formatting my disk a number of times." "Even you, Doctor?" "Even me," I let out a sigh. "FORMATting your hard disk is just an accident waiting to happen." 2:57pm "Why doesn't IBM put some kind of protection in the FORMAT command?" "The newer versions of DOS do contain a special confirmation message, to warn you when you are about to format a hard drive. You have to answer 'Y' to continue, instead of simply striking any key." "Well, there still are a lot of us using our original version of DOS. Doctor, isn't there some way we can prevent this problem from ever recurring?" "Most Bulletin Boards have instructions for patches, so you can modify FORMAT.COM using DEBUG." Mr. Y. shook his head. "I never used DEBUG." "Okay then, there are several safeguard products available." I recited a couple names: Norton, MACE, PC-TOOLS, and some public domain utilities. "They copy the F.A.T. information elsewhere on the disk, so you can always recover from damage to the F.A.T. Just stick one in your AUTOEXEC.BAT and it protects you automatically every time you boot up." "But we're not going to run out and buy everyone a utility, just to prevent a once-in-a-lifetime mistake. I want something we can use company-wide. Isn't there something simple we can all use?" 2:59pm I thought about it for a moment. "The simplest solution, is to delete FORMAT.COM off your hard disk all together. Then, whenever you open a new box of diskettes, format them all at once, using the FORMAT command off your DOS disk." Mr. Y smirked. I could see he didn't like that approach, so I continued, "Here's another idea that's more convenient. Rename FORMAT.COM to something like WATCHOUT.COM . That way, you'll never use it without thinking twice." "In fact," I had an idea, "if you write a FORMAT.BAT batch file, that would prevent you from formatting the wrong drive." "Can you show me how to write a batch file? Or better yet, why don't you write it down, and I'll put it in our user group newsletter, so everyone will read it." "Ok." I said, then I reconsidered. "We can get people to read it, but how can we get people to take action on it?" "That's my job," Mr. Y. smiled with a powerful grin. "I guarantee everybody who works for me will do it." ========================================= Prevent Accidental Formatting of C: by the Disk Doctor -------------------------------------------- Copyright (C) 1987, the Disk Doctor. First published in the Rochester (PC)^3 News: Picture City PC Programming Club PO BOX 20342 Rochester, NY 14602 The Disk Doctor may be contacted at this address, or via CIS [73147,414]. This material may be reproduced for internal use by other not-for-profit groups, provided this copyright notice is included. ---------------------------------------------- We are going to create a FORMAT.BAT. The first step is to rename FORMAT.COM. This is necessary because a batch file has lower precedence than a .COM program by the same name. If you are a new user, or someone else set up your machine for you, you may need help finding the file FORMAT.COM. If you know where to find it, skip the next paragraph. Display your path environment by entering the command 'PATH' . The response may list several sub-directories, like this: 'PATH=C:\;C:\DOS;C:\MENU;... '. Most people keep all their DOS commands in one sub-directory named \DOS or \SYSTEM or something like that. These commands are always available, no matter where you are, via the PATH link. Examine the various sub-directories where you expect to find DOS commands. You can do this with the command: 'DIR \SYSTEM\FORMAT.COM' (or whatever). Change to this sub-directory with the command 'CHDIR \SYSTEM' (or whatever). Rename this file to something omenous. 'REN FORMAT.COM WATCHOUT.COM'. Create a batch file in this directory with the command: 'EDLIN FORMAT.BAT'. Type 'I' for insert, and enter the following: ECHO OFF REM THIS COMMAND WILL ONLY FORMAT A: IF A:==1% GOTO OKAY IF a:==1% GOTO OKAY ECHO YOU FORGOT TO SPECIFY THE DRIVE LETTER... ECHO THIS MISTAKE COULD FORMAT YOUR HARD-DISK. ECHO IN THE FUTURE, BE MORE CAREFUL. ECHO NOW RE-ENTER THE COMMAND CORRECTLY. GOTO DONE :OKAY WATCHOUT %1 %2 %3 :DONE After you have entered these lines, press Ctrl-ScrollLock(Break), then 'E' to exit EDLIN and save this batch file. As written above, FORMAT.BAT will only allow you to format drive A:. If you have a second floppy drive, you may want to insert after the fourth line: IF B:==1% GOTO OKAY IF b:==1% GOTO OKAY If you do intend to format any another drive, you can also invoke the renamed command directly: 'WATCHOUT B:'. From now on, when you type 'FORMAT', it will invoke this batch file instead of the original FORMAT command. Any time you leave off the parameters (the drive letter to be formatted), you will get an error message instead. If you use the /S or other options, be sure to put them last on the command line, or FORMAT.BAT will give you a nasty message and FORMAT will not run properly. NOTE: I have written FORMAT.BAT to force you to enter the command correctly. I could have simply ignored the error and proceeded to format drive A:, but I believe users should be educated, not shielded from their mistakes. If you get in the habit of leaving off the drive letter, one day you will make this mistake on someone else's machine, someone without FORMAT.BAT protection. Let's be safe and learn to do it right. REMEMBER: The single best insurance against all types of disk problems is frequent, thorough backups.