Create MSDOS Batch Files to Automate the Task
I am going to show you how to make (provide for you) MSDOS batch files that will do this for you flawlessly and easily. All you’ll have to do is double click the batch file from anywhere in Windows when you want to create or update your backups. Also, you’ll make a restore batch file that you execute from the Command Prompt (only).
A batch file is basically a text based file that contains DOS commands that are executed in sequence when you run the batch file. Batch files can be very powerful and can use simple programming commands as well. I recommend that you never run a batch file unless you view it and understand the commands that it is going to execute. While I would never do anything to harm you, some cretinous wretch could wipe you out with a single command in a batch file. For that reason I am going to go through the batch file with you step by step and explain the commands.
If you are running Windows 98 and are not interested in the batch files, scroll down because I will also be providing information on how to effectively use the Windows 98 Registry Checker and the Scanreg utility to backup and restore configuration files. I will also provide information on how to use Regedit (Win95 and Win98) to make an additional registry backup.
Backup Config Files – cfgbak.bat (Example)
@echo This batch file must run from within Windows 95 or Windows 98
if EXIST c:\cfgbak\* goto next
echo CREATING DIRECTORY C:\CFGBAK
attrib -h -s %windir%\system.dat
attrib -h -s %windir%\user.dat
attrib -h -s c:\msdos.sys
copy /B %windir%\system.dat c:\cfgbak /B /V /Y
copy /B %windir%\user.dat c:\cfgbak /B /V /Y
copy c:\msdos.sys c:\cfgbak /V /Y
attrib +h %windir%\system.dat
attrib +h %windir%\user.dat
attrib +h +s c:\msdos.sys
copy %windir%\system.ini c:\cfgbak /V /Y
copy %windir%\win.ini c:\cfgbak /V /Y
if EXIST c:\autoexec.bat copy c:\autoexec.bat c:\cfgbak /V /Y
if EXIST c:\config.sys copy c:\config.sys c:\cfgbak /V /Y
The first line is telling you (will echo to your screen) that the batch file is to run from within Windows 9x and not from command prompt. The reason for this, is that I’m using the %windir% variable which if not used from within Windows, will return the root directory, which is not what we want and will result in file copy error messages. Not everyone’s Windows directory is C:\Windows. The next line @echo off turns off the echo so the rest of the process won’t make a mess of your DOS window. The @ tells it not to echo the echo command.
Next, if the directory c:\cfgbak exists, the process will proceed to the commands defined under “next”. If the directory doesn’t exist, the “md” command that follows will create it.
Next, we are removing the MSDOS file attributes necessary to copy the files (you guessed it, the command is attrib).
Next we are copying the two files that make up the system registry, and the file MSDOS.sys. Note the switches I am using with the copy command. The /B switch specifies that it is a binary file (by default, copy treats files as ascii). This switch is not really necessary under normal circumstances, but since these are very important files I want to take extra precautions to ensure that the files are written and verified correctly. Using the /B switch ensures that the entire file is copied, regardless of any file markers within. The /V switch verifies the source and destination files to ensure that they are identical (eg. not corrupted). The /Y switch suppresses prompting when files are overwritten. This is necessary because the batch file is to be used not only to create the backups but to update them on a regular basis.
Next, we reset the MSDOS attributes that we changed. This is important so that the files are protected. Win.ini and System.ini do not have attributes that need to be removed and they are ascii text based files so we simply copy them. Autoexec.bat and Config.sys may not be present on your system, as if all your hardware is plug and play and you do not run DOS programs or load any real mode drivers they are not needed. If they exist, however, they will be copied. Note that if they are blank (0 byte) files, they will not be copied and you will see a “(0) files copied” line in the output of the batch file. This is nothing to worry about.
You can either copy the text from the textbox to notepad and save it as cfgbak.bat (or any other name with the extension.bat), or you can download the zip file. Note that I left the batch file to restore the backups as a text file. (restcfg.txt) You will have to rename it so it has the extension .bat and/or edit it. (I did this just as a precaution, so someone doesn’t immediately run it by double clicking)
Get cfgbak.zip (cfgbak.bat and restcfg.txt)
How to Use this Batch File
Simply copy it to any folder in Windows or put it on your Desktop. Double click it at any time to create or update your backups. If you want to add more files to be backed up, or you want to change the location of the backup destination, I think I have provided you enough information so you can edit it yourself. Once again, feel free to Email me. Be careful with the placement of command line switches.