How to add a shared printer using a one-click script? … and how to configure printer with no drivers for it

I was just working on a task today where two printers has been purchased for one of the office I support. The problem was, there are no Windows 2003 Server x86 drivers available for this printer as it is “too new” for the system and the printers must be shared from this server to … Windows 7 x64 machines.

So, the first problem was to get the printer working on Windows 2003 Standard Edition Server … somehow … with some driver. The printer was HP OfficeJet 7612. After few attempts  I got it working with HP DeskJet 864C x86 driver available from Windows “Add Printer Driver” list.

Here’s step by step, in case someone out there on interwebs has similar task and is now sitting and scratching his head:

– create new local printer port /Add printer/Local printer attached to this computer/Create a new port/ and select “Standard TCP/IP Port”, click “Next” and as type in printer’s IP address to both “Printer Name or IP Address” and “Port name”

–  once you have port created, the next step will be drivers, select driver from the list and click “Next”, then finish installation, print the test page to make sure its working OK.

– now, share your printer. If you click on “Additional Drivers” under the “Sharing” tab, you’ll notice there are no x64 drivers available. In many cases like this one, there are no x64 drivers available to download from manufacturer’s website at all and the only place to get them from is Windows Update (bear in mind you need x64 driver for DeskJet 864C printer as this is how your server see your nice and new OfficeJet 7612) Why is that? Because all older pre Windows 7 released USB printers are now plug-and-play.

– so to get the x64 driver, logon to Windows 7 (8) machine and add the printer the same way as you did on the server, by creating local TCP/IP port using printer’s IP address and selecting HP DeskJet 864C or whatever is your substitute driver for your printer. Once printer is configured, test if it prints OK.

– now you need to export and enable your x64 driver from your Windows 7 to your Windows 2003 server. On your Windows 7 (or 8) machine , click  “Start” and then browse to \\server\ , then click on “View remote printers” and next right click on your printer and select “Properties”, click “Additional drivers” and select x64 – this will copy printer driver from your Windows 7 (or 8) machine onto server and make them available for other users.

Now you can add your printer using \\server\printername path or … bellow script.

Script obviously works for any shared printer, as long as the path is correct and there are printer drivers available on the server. You can save it as addprinter.bat and push it to user’s desktops.

color 1E
cls
@echo off
@echo Configuring your network printer
@echo Please wait...
@Echo.
@Echo.
@Echo.

rundll32 printui.dll,PrintUIEntry /in /n\\servername\printername

In another scenarios , for network printers, you may want to try a script that creates local TCP/IP printer port, downloads and install driver and adds the printer.

CLS
@ECHO off

SET varIP=10.10.12.23
SET varDriver=HP OfficeJet 7612
SET varDriverFolder=\\Server\yourdriverfolder\driverlocation\
SET varDriverFile=\\Server\yourdriverfolder\driverlocation\driverinffile.inf
SET varName=My new printer
SET varLocation=My office

REM "Deleting TCP/IP port"
CSCRIPT /nologo %windir%\system32\prnport.vbs -d -r IP_%varIP%

REM "Creating TCP/IP port"
CSCRIPT /nologo %windir%\system32\prnport.vbs -a -r IP_%varIP% -o raw -n 9100 -h %varIP%

CLS
REM "Installation message"
@ECHO.
@ECHO The %varLocation% printer is currently being installed.
@ECHO.
@ECHO Please do not close this window.
@ECHO.
@ECHO Once the installation is complete this Setup window will exit.
@ECHO.

REM "Driver installation"
CSCRIPT /nologo %windir%\system32\prndrvr.vbs -a -m "%varDriver%" -h "%varDriverFolder%" -i "%varDriverFile%"  
CLS

REM "Printer deletion"
@ECHO.
@ECHO Completing installation.
CSCRIPT /nologo %windir%\system32\prnmngr.vbs -d -p "%varName%" 
CLS

REM "Printer installation"
@ECHO.
@ECHO Completing installation.
CSCRIPT /nologo %windir%\system32\prnmngr.vbs -a -p "%varName%" -m "%varDriver%" -r "IP_%varIP%"
CLS

REM "Location configuration"
@ECHO.
@ECHO Completing installation.
CSCRIPT /nologo %windir%\system32\prncnfg.vbs -t -p "%varName%" -l "%varLocation%"
CLS

REM "Making it Default printer"
CSCRIPT %windir%\system32\prnmngr.vbs -p "%varName%" -t

Just a side note at the end. I’m a Linux user for years now. As you see above, doing this on Windows already is, I’d say, not straight forward, but on Linux this would be like wiping the ass with a sandpaper.

 

Leave a Reply