When I last supported an organization with Windows 98 workstations, I was confronted with a host of recurring problems that required frequent operating system reinstalls. I often couldn’t reinstall over the existing Windows installation because Setup would try to preserve the configuration files that were causing the problems. This meant I had to remove the existing Windows installation before installing a new copy. To further complicate the situation, the end users in this particular organization kept sensitive data on their workstations, making it impossible to simply reformat their hard drives.
To solve this dilemma, I used a simple boot disk to remove all the Windows files. Once this was finished, I could manually remove the files associated with Windows. (I would have automated this process, but there were too many variations among installed applications.) When the old copy had been removed, I would reinstall Windows onto the machine. However, the process wasn’t as simple as you might expect.
My simple Windows 9x/Me removal batch file
One of the issues that I ran into is Windows’ tendency to have a lot of hidden, read only, and system files. Until these files are removed, you can’t delete the Windows directory. Also, there was a lot of wait time involved in manually removing Windows from a machine. I solved both of these problems by using a simple batch file to automate the removal process. The batch file was similar to the one shown below. Keep in mind, though, that you’ll have to modify the batch file to reflect your actual drive letters and paths.
ATTRIB *.* -S –H –R /S
ATTRIB *.* -S –H –R /S
The first line switches to the C: drive. This line is necessary because if you run the batch file from your boot disk, the command prompt will be set to the A: drive rather than to C:.
The next line switches to the Windows folder. After doing so, the ATTRIB *.* -S -H -R /S line removes the hidden, read only, and system attributes from the Windows directory. The /S switch tells the ATTRIB command that these attributes should also be removed from files in all subdirectories.
The next line switches to the root directory, and the DELTREE C:\Windows command erases the Windows directory and everything in it. The next group of commands repeats the entire process with the TEMP folder. Depending on your Windows version and configuration, this folder could be named TMP instead of TEMP.
Three considerations when creating your own batch file
Before you use the batch file, let me explain some things you should consider. First, you might have noticed that I left the root directory alone. Windows 9x and Windows Me don’t place many files in the root directory. Typically, the only system files in the root directory would be IO.SYS, MSDOS.SYS, and COMMAND.COM. In my experience, these files rarely become corrupted, and it’s usually okay to leave them in place for your Windows reinstallation. The biggest exception would be a situation in which someone had altered the MSDOS.SYS file in an undesirable way. And, depending on your version of Windows, there may be a swap file (sometimes called a page file) in the root directory as well. Again, you don’t have to remove this file.
You must also be very careful with the drive paths and the commands you use within your batch file. For example, you might have noticed that I used the DELTREE C:\Windows command instead of switching to the Windows directory and using the ERASE *.* /S command. There are three main reasons for this:
- The DELTREE command will remove the empty subfolders, but ERASE won’t. That isn’t a real big deal if you’re going to be reinstalling Windows, though.
- The DELTREE command asks for confirmation before deleting anything. Of course, confirmation is a bad idea if you’re planning on running the batch file and walking away. You can get around the need for confirmation by adding a /Y to the command. For example, you might use the command DELTREE /Y C:\Windows.
- The ERASE command doesn’t care about the path, but DELTREE does. Imagine that the line before the ERASE command was CD\WINDWS. (Notice that I intentionally misspelled Windows.) The CD command would realize that the WINDWS directory doesn’t exist and would therefore remain in the current directory. ERASE would then remove everything from the current directory rather than from the intended directory, which should have been WINDOWS.
The final thing to remember about this batch file is that any time you need the batch file to switch to the root directory, use the CD\ command instead of the CD.. command, because CD\ always goes to the root directory, while CD.. simply drops down a level. In this particular batch file, either command would have worked, but I like to be absolutely certain about my paths—especially when the batch file is designed to delete things.