Windows apps: Before and After. (batch files for software installation) (Column)
by Clifton Karnes
Not long ago each PC program came in a single COM file, less than 64K in size. You didn't really install a program in those days--you just copied it to a floppy disk and ran it.
The next level in size escalation came when programs started to require overlays, which allowed parts of a program to be shuttled in and out of memory as needed. And as programs became more complicated, additional support files for printing and various other things were added. To install these programs that occupied several files, you simply copied all the files on the distribution disks to your hard drive.
Things are not so simple in Windows-land. Windows apps can use scores of files, and the installation programs are notoriously sloppy about distributing these files all over your hard disk as well as making changes to your CONFIG.SYS, AUTOEXEC.BAT, WIN.INI, SYSTEM.INI, or all four.
Typically, a program will deposit its main files in a special subdirectory (or group of subdirectories) it creates on your hard disk, and it will add an INI file to your Windows subdirectory. It may also add a file or two to your SYSTEM subdirectory. And it will probably alter your AUTOEXEC.BAT (to include itself on your already bulging path), perhaps add a driver or two to your SYSTEM.INI or CONFIG.SYS files, and almost certainly make some entries to your WIN.INI file.
There's really no problem with all of this until you want to get rid of one of these programs. Where are all the files? And what changes were made to your system files that you need to undo?
Because Windows programs tend to install files in so many subdirectories and alter so many files, each program should have its own uninstall option. I've never seen one that does, however.
Here's a solution. With the two batch files listed below, called Before and After, you can create a list of all the changes a program makes when it installs itself.
The principle is simple. You run Before before you install any new software. It makes a list of every file on your hard disk. To this list it appends the contents of your CONFIG.SYS, AUTOEXEC.BAT, WIN.INI, and SYSTEM.INI files.
Next you install your software, and after you've finished, you run After. The first thing After does is make a list of all the files on your system and the contents of your system files, just like Before has done. But this list includes the files added by the program you've just installed as well as any changes made to your system files. Next, After compares the list it's just made with Before's list. Any files added or deleted from your system show up in the comparison, as well as any changes to your system files.
Here's the listing for BEFORE.BAT:
@echo off cls c: cd/windows echo [BEFORE] Recording files on disk (this will take a while) ... chkdsk/v>c:snapshot.tmp echo [BEFORE] Checking system files ... copy c:snapshot.tmp + c:/autoexec.bat + c:/config.sys + c:/windows/win.ini + c:/windows/system.ini c:before.txt >nul echo [BEFORE] Cleaning up ... erase c:snapshot.tmp cd/
The CHKDSK command with the V switch isn't used very often, but it's great for us. It causes CHKDSK to list every file on the disk with its complete path. We redirect its output to SNAPSHOT.TMP.
The next step is to append the system files to SNAPSHOT.TMP and store the complete list in a new file, BEFORE.TXT. Now we have a snapshot of our system before we install a new program.
Here's the listing for AFTER.BAT:
@echo off if "%1" == "" goto end cls c: cd/windows echo [AFTER] Recording files on disk (this will take a while) ... chkdsk/v>c:snapshot.tmp echo [AFTER] Checking system files ... copy c:snapshot.tmp + c:/autoexec.bat + c:/config.sys + c:/windows/win.ini + c:/windows/system.ini c:after.txt >nul erase c:snapshot.tmp echo [AFTER] Checking for changes ... fc c:before.txt c:after.txt >c:%1
type %1 more
goto stop :end echo Please specify a filename for the changes. :stop
When you run After, you'll need to specify a filename for the changes it finds.
The first few lines of After do just what Before does--they make a snapshot of your system.
The line fc c:before.txt c:after.txt >c:%1 compares the two snapshots and puts the results in the file you specified on the command line.
You can then use the file created by After to locate the files introduced and altered by the installation.