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.

How to Create (but not add) a Printer in WinNT

Keywords:  printer print   

Question:

We're looking for a way to create printers on an NT 4.0 machine. Does anyone know how to do this? I couldn't find a Winbatch routine, and am not sure if it can be done via the registry.

Answer:

See the Printer Control Extender function pAddPrinter. pAddPrinter adds a printer to the list of supported printers for a server.

or it can done via the registry.

  1. Find a machine without the printer installed.

    Get the SYSDIFF utility (check your NT directory you might have it) otherwise snag it from www.microsoft.com and make the "before" file.

  2. Install the printer.

  3. Run SYSDIFF again.

    Figure out what it did to the registry and re-create it via WinBatch.

  4. Then you may need to reboot (IntControl 66,67,68 or something) or maybe send a message... Ummm...

;;32 bit Devmode.wbt

DMC=27
                      
DaDll=Strcat(DirWindows(1),"USER32.DLL")
DllCall( DaDll, long:"SendMessageA", long:-1, long:DMC, long:0, lpstr:newdevice)

Once you've changed the device, you can broadcast a WM_WININICHANGE message to all interested parties in the system to make the printer changes in the registry take effect, so that applications (such as Program Manager, Task Manager, Control Panel, and so forth) can perform an update. An WININICHANGE message (=26) is required for some cases, so it probably would not hurt to do both of them (the WININICHANGE and the DEVMODECHANGE).

The WININICHG is for telling running applications that WIN.INI has changed. Newly run applications will pick up the environment automatically, done as follows:



WININICHG=26
DaDll=Strcat(DirWindows(1),"USER32.DLL")
DllCall( DaDll, long:"SendMessageA", long:-1, long:WININICHG, long:0, lpstr:newdevice) 
Also See (and understand):

Changing Windows 95 and NT Default Printer

Article ID:   W13689
Filename:   Create but Not Add Printer in WinNT.txt
File Created: 2017:08:29:11:58:50
Last Updated: 2017:08:29:11:58:50