
                          Print Manager Watcher
                               Version 1.1


                             by Brad Choate

                            Choate Consulting
                         1402 West Center Avenue
                            Searcy, Arkansas


INTRODUCTION


        Here lately I have found myself installing several Windows for
Workgroups networks instead of Netware or LANtastic networks.  Of course,
with any new networking system you get to find out it's pluses and minuses
within a relatively short period of time of the implementation. Your users
are usually the ones that introduce you to these problems. This document
will describe one of the problems I found with Windows for Workgroups and
also discloses how I resolved it.

        When you install a Windows for Workgroups network, one of your
tasks is to set up print sharing.  This is a relatively easy task
actually, and I'm not going to document that.  However, there is one
important thing to remember about printer sharing with Windows for
Workgroups.  In order for a computer to share a printer with the network,
it must run the Windows Print Manager program at all times.

        Print Manager is necessary because it handles the collection and
spooling of data from both the local machine and from other machines on
the network to the shared printer.  It also handles all the other local
printers that are attached.  If you attempt to close the Print Manager on
a computer that is sharing printers, it will warn you that doing so will
prevent it from servicing the other computers on the network for the
printers your computer shares.

        The real problem here is that some of my Windows for Workgroups
clients do not understand this command although it is in simple English.
Against my instructions, they continually close the Print Manager every
time they get into it (deliberately or otherwise).  I cannot give the
exact reason why they think they must close the program.  Perhaps they
don't understand that Windows multitasks and the program can continue to
run while they go back to their word processor.

        Nonetheless, the program does get closed and the next time a
remote station tries to print to that printer, they get an error and
immediately call me.  I then spend 10 to 15 minutes walking my client
through going to the print server machine and manually starting the Print
Manager again.  After doing this more times than I wish to count, I
decided to write a small program to address this problem.

        I named this program "Print Manager Watcher" and I believe the
name adequately describes it's function.  It's sole task is to sit around
and every now and then check to make sure the Print Manager is still
running.  If it isn't it will load it.  It's that simple.  I have never
had to tell a user how to load the Print Manager once this program has
been installed.


INSTALLATION


        When I decided to release this utility to the public, I planned to
direct it to consultants and other developers.  Therefore, I didn't really
plan on creating an installation program, but I did so anyway because I'm
a perfectionist and cannot stand doing anything halfway.  Frankly this
tool is so simple, I hardly think it deserves such thorough documentation,
but the documentation is for you and not me, so I can only hope it is of
use to you.

        Whenever I go to a client to install this utility, I take my PMW
installation diskette and I run A:SETUP from it.  Since you downloaded
this tool, it is not already on diskette, but here is how you can set up
an installation diskette:

        1)  If you downloaded this program, the file was named
            PMW????.EXE where ???? are the platform and version numbers.
            Currently the only platform supported is Windows for
            Workgroups 3.1x, so the first two digits are 31.  The last two
            digits are the version numbers.  Currently, this is version
            1.1, so the digits will be 11.  The entire name should be
            PMW3111.EXE at this time.  The last two digits would be the
            first thing to change in the near future.
        2)  Take this executable and a blank, formatted diskette.  Place
            the diskette into the appropriate drive (I'll refer to that
            drive as drive A: from here on even if on your system it may
            be drive B:).
        3)  At the command prompt, type "PMW3111 A:" (minus the quotes)
            and press enter.
        4)  If all files were verified, then the diskette is a good one.
            Regardless, now would be a good time to virus check the
            diskette.
        5)  Go to your client's site and to the computer that is sharing
            printers.
        6)  From the Program Manager, select the File menu, then choose
            "Run...".
        7)  Insert the PMW Install diskette into the client's diskette
            drive.
        8)  At the command line prompt in that dialog, type
            "A:SETUP" (minus the quotes), where A: is the drive letter for
            the drive containing the PMW Install diskette.
        9)  Once the program reports that the installation is complete,
            remove the diskette from the drive.
        10) You may want to explain to your client what you have done and
            why it was important.


        One of the files on the installation diskette will be named
"PMW.INI".  It contains the default values for company name, company phone
and the interval for checking the Print Manager.  Feel free to change
this INI file to reflect the name and phone number for your company.  When
the program is installed, it will copy the INI file as is to the target
hard drive.


        To make things easier, I decided to install PMW to the Windows
directory.  While I am usually opposed to applications adding their own
files to the Windows tree, I don't mind this so much since it is a utility
that only amounts to two files.  Uninstalling PMW is easy:  delete
"PMW.INI" and "PMW.EXE" the Windows directory and remove "PMW.EXE" from
the "LOAD=" part of WIN.INI.  If you are a consultant worth your salt, I
don't have to explain any more than that.


        Once installed, PMW will load itself automatically each time
Windows is loaded.  It will never be "seen" since it keeps hidden from
view.  But, you will notice that if you ever close the Print Manager, PMW
is back there to reload it once the specified time interval has elapsed.


HOW IT WORKS


        Once the program has been installed, this is how it functions.
First of all, it is loaded every time Windows is started (it is added to
the "load=" line in WIN.INI).  This is important because we want to make
sure the program is loaded without the user having to manually start the
utility.  Also, the program is not loaded from the startup group because
the user could potentially remove it by mistake.  By placing it on the
"load=" line in WIN.INI, it is "hidden" from most users and keeps them
from disabling the utility.

        When loaded into memory, the program creates a timer for itself.
It will check for the Print Manager every 65 seconds (this interval is
configurable).

        At every 65 seconds after the program has been loaded, it checks
for the Print Manager.  If it is running, the program does nothing but
resumes its wait for the next check.

        If the Print Manager is not running at one of these intervals, the
program initiates the following procedure:

        1)  It checks the SYSTEM.INI file for the "spooler=" line.  If it
says "no", then it sets the "spooler=" value to "yes".

        2)  It then starts the Print Manager forcefully.  First of all, it
starts it minimized and secondly, it never allows the Print Manager to
receive the window focus. Therefore, the program could start the Print
Manager in the background while your user is working on their documents
and they would never know it.


REQUIREMENTS


        I wrote the Print Manager watcher with the goal in mind that it be
a small, useful utility that would not add any real overhead to a user's
system.  I believe that I have achieved that goal.  PMW is a very small
application.  Written in Borland Pascal for Windows, it is one of the
smallest Windows applications you can find.  It shouldn't be large anyway,
since it has a very simple task to accomplish.

        The program does use one timer but that shouldn't be a problem.
It also creates a window (as all Windows programs do, hidden or not).  But
all of these resources are very small and will not impact any system to
any noticeable degree.  The PMW application cannot be unloaded until
Windows itself is closed down.  That is when it releases any resources it
allocated when it was started.

        In short, it requires Microsoft Windows or Windows for Workgroups.
It is intended for Windows for Workgroups primarily.  I have not tested
this utility with Windows NT 3.5x, but if NT requires the Print Manager
for sharing printers, it should still work.  I haven't tested it with
Windows 95 either but I'm sure it won't work there.


REGISTRATION


        To be honest, I don't expect to have many people "register" this
product.  Therefore, I'm not wasting time with a "nag" screen or an
encrypted registration key or anything like that.  I'm making this
available so it will help other people like me.  If you find that this
utility is useful and that it is worth something to you, I simply ask that
you pay me what you feel it is worth.  If you do this, please include your
e-mail address with payment so I can notify you of future updates.
Please, one check per person... don't register for each client use this
utility for (unless you really want to).


SOURCE CODE


        If you are interested in getting the source code for this utility,
I do ask $10 for it.  Please understand it is written in Borland Pascal
for Windows, but can easily be converted to C/C++.  Please make your check
payable to "Choate Consulting" and send it to the address at the top of
this document.


APPENDIX A:  Error Codes


        If the program ever gives the user an error message, it will
include a number in parenthesis.  This number is the error code and will
be one of the numbers below (please note, most of these errors are direct
from the result codes of the Windows API function WinExec.  I doubt you
would ever see most of these codes, but I have included all of them to
provide you with an exhaustive list):

Value       Meaning
==========  ===============================================================

0           System was out of memory, executable file was corrupt, or
            relocations were invalid.

2           File was not found.

3           Path was not found.

5           Attempt was made to dynamically link to a task, or there was a
            sharing or network-protection error.

6           Library required separate data segments for each task.

8           There was insufficient memory to start the application.

10          Windows version was incorrect.

11          Executable file was invalid. Either it was not a Windows
            application or there was an error in the .EXE image.

12          Application was designed for a different operating system.

13          Application was designed for MS-DOS 4.0.

14          Type of executable file was unknown.

15          Attempt was made to load a real-mode application (developed
            for an earlier version of Windows).

16          Attempt was made to load a second instance of an executable
            file containing multiple data segments that were not marked
            read-only.

19          Attempt was made to load a compressed executable file. The
            file must be decompressed before it can be loaded.

20          Dynamic-link library (DLL) file was invalid. One of the DLLs
            required to run this application was corrupt.

21          Application requires 32-bit extensions.

32          Error writing to the win.ini file (setting spooler=yes)

33          No timers were available to start Print Manager Watcher.


APPENDIX B:  Revision History


Version     Changes
==========  ===============================================================
1.1         Support for a PMW.INI file that contains defaults for
            technical support information and time interval for timer.

            Added error code #33 which occurs when no additional timers
            are available.

            First distributed version.

1.0         Creation


APPENDIX C:  Technical Support


        If there are any questions concerning the operation of this
program that have not been addressed within this document, please forward
them to me at this address:

   choate@cswnet.com

        Please do not call me on the phone, nothing could be so urgent.


APPENDIX D:  Warranty or Guarantees


        I'm sure everyone has seen this before, but I must include it.

        I am releasing this product that I have used in my own consulting
work into the public.  I do so without offering any guarantee or warranty
of it's use and effectiveness.  Anyone that uses this utility, the
installation program provided with it and all other files included does so
at their own risk.

        I have taken every precaution to make sure this program is
distributed as virus-free but I do not guarantee that it is.  I have no
control over where the file I upload goes once it is placed in
"cyberspace".  Therefore, I cannot insure that it is 100% protected from
any alien forces it encounters (such as viruses).  I do warn the reader
that they should virus check any software they download from any online
source no matter how credible.  And be very sure you virus check any
diskette you prepare to take to a client's computer.  I can get away with
not guaranteeing my software, but you can be sure that the client expects
you to guarantee your work... especially if it gives them a virus.

        In summary:  here it is, use at your own risk, no guarantee or
warranty, and no refunds.


DISCLAIMERS


        All references to Microsoft's Windows, Windows for Workgroups,
Windows NT, Windows '95, etc. are registered trademarks of their
respective owners.