Your basic ITPro blog... What's going on at work, what I'm interested in.

Monday, September 15, 2008

Automating Printer Configuration

I have been asked about this numerous times as part of my desire to automate our account/computer set-up and tear-down procedures. Every time we configure a computer, we have to install printers. This involves creating the Standard TCP/IP Port and installing the printer itself, including drivers. We may be doing this for three or more printers. This task get tedious when doing it through the GUI. So, I have finally began working on how to help automate this job...

  1. First things first. Printer port configuration is stored in the registry.  You find it at: [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\<PortName>]. Export the key for the port you need. This will be merged on our new install later.
  2. Next, we use the printui.dll to install the printer and its drivers. There are two main commands here... First, install the printer. Second, import the configuration settings that were exported from an already-configured computer.
  3. A couple of restarts to the spooler service, and we are ready to go!

From here, I created a .CDM file that performs the following steps:

  1. Import .reg file with printer port configuration
  2. Stop/Start Spooler service
  3. Install printer, including driver
  4. Import printer configuration
  5. Stop/Start Spooler service

Here's the actual code in one of my CMD files:

regedit /s z:\canonC3200PrinterPort.reg

net stop spooler
net start spooler

start /wait rundll32 printui.dll,PrintUIEntry /if /b "CanonC3200" /f "\\<UNC_Path_To_INF_File>\oemsetup.inf" /r "canon3200" /m "Canon iR C3200-C1 PS Ver1.0" /z

start /wait rundll32 printui.dll,PrintUIEntry /Sr /n "CanonC3200" /a "Z:\canonc3200.dat"

net stop spooler
net start spooler

Hopefully, this will make printer setup a bit easier in the future.

*Some of the resources I used to figure all of this out:

No comments:

Additional Info

My photo
email: support (AT) mangrumtech (DOT) com
mobile: 480-270-4332