WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Printing Information

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Capturing Printer Port

Keywords:     NetAddPrinter    n4captureprt 

Question:

I am trying to use WinBatch to automatically capture my network printer to LPT1:. There are several network printers here and in order to print to Lotus Notes, the printer must be captured to an LPT port. With everyone here changing jobs constantly it is too difficult to use WIndows' GUI to capture the port since EVERY user has to do it.

I think I have found all the registry keys.

The network printers already exist and are in the printers menu. I just need to change the port capture in a simplified manner.

Answer:

Basically a NetAddPrinter ought to do most of it.

The function does not add a printer to the printer menu, just to the copy of currently running Windows. It maps drivers very well. Note that AddPrinter is not an InstallPrinter. The "AddPrinter" types of functions simply "map" or "Connect" a pre-existing printer.

Adding a printer to the printer menu is much more of a fight.

Question (continued):

Well, I finally was able to get the LPT: port captured to the network printer. My only problem now is changing the newly captured printer to print to LPT1, and setting the old printer back to print to its network port. Right now I'm having to do this manually in the Printers folder and going to properties of the new printer and old printer.

Answer:

The trick is to do the following.
  1. Before any changes, examine registry (If running NT see the sysdiff utility in NT resource kit) for entries concerning the printers.

  2. Make the changes. Record Registry changes.

  3. Change it back. Should be same as #1.

  4. Now write a script to update the registry and hack thru the DMC change SendMessage to tell the system you've updated everything.

Question on Capturing NETWARE Printer Port:

What I am trying to accomplish is a simple way for our users to switch between printers. Some of the printers are on the network and one printer is physically attached to the workstation. All of the scripts work fine independently, the problem is as follows.

If a user boots up, chooses the winbatch script to print to a network printer, prints (successfully), and then chooses to switch to the local printer it will not work.

If the user boots up, chooses the local printer script, prints, everything works fine all day. As long as the user prints to the local printer first, everything is ok...

The problem is when the user prints to the network first, where I'm doing an n4CapturePrt. Is there something else I can put in the script to not cause this problem? I am using the newest version of Winbatch.

Answer:

Make sure you do the DMC-27 stuff in the example below:

;;32 bit Devmode.wbt
;;WM_DEVMODECHANGE (DMC) message:

DMC=27
                      
DaDll=Strcat(DirWindows(1),"USER32.DLL")
DllCall( DaDll, long:"SendMessageA", long:-1, long:DMC, long:0, lpstr:newdevice)
Message(0,1)
Do the n4CaptureEnd at the end of your network printer script before running your local printer script, since you can't set a local printer to print to a LPT port that has been captured to a network printer queue.

From your description it looks 99% like you are getting the registry and win.ini settings very very very close, and when you first print to the local printer it is close enough for windows to guess at the correct solution.

The idea is to capture the registry and the win.ini and the system.ini file before AND after the first local print and compare them to see what got fixed. Then change the script accordingly.

If that doesn't work, the only real short-term solution, considering we're stumped to, it to try to make a BAT file that does what you need.

Once you get that far, we can run the DOS BAT file as a hidden window so no one ever sees it.


Article ID:   W13683
Filename:   Capturing Printer Port.txt
File Created: 2002:02:12:15:58:12
Last Updated: 2002:02:12:15:58:12