The first snippet of code was designed to be run to install the handler or designed to be a stub exe to be executed prior to the program using the handler. In other words the parent EXE would execute the stub first to install the handler. The problem I ran into was that because it was not an actual TSR there wasn't any good way to uninstall the handler. But what I did is when the exe is executed it queries the keyboard interrupt and checks the return code. If my handler is already installed it will return a value indicating it is already there. But if the old handler is there it won't know how to deal with the interrupt and will not return the correct value. This is how a lot of programs in the old DOS days checked to see if they were installed.
If you want to make this a true TSR then you can do so, just make sure you limit the actual TSR portion to the relevant code only. For information on how to correctly use TSRs in DOS consult Randall Hyde's Art of Assembly Language Programming or the DOS 6.20-6.22 technical reference manual.