3

I want to be able to create a BATCH script that will add a printer locally using the TCP/IP port. I am assuming the arguments needed would be the printers name, driver location (.inf), IP address, and computer name.

Anyone able to help?

1 Answer 1

5

You can accomplish this with a few calls to printui - see this page for more information. It sounds like you would want to call

rundll32 printui.dll,PrintUIEntry /ga

Though I am not certain how to specify a printer via INF file over the network.

A few years ago, I wrote a script to install printers over the network. This script is intended for use with printers shared over samba, so you don't need to specify a driver. If you're trying to add a printer that isn't shared in this way, I'm not sure that this will work. Perhaps you can use this as a starting point though to figure out how to do it.

@echo off
::
::This script adds a single printer to the default user profile.
::NOTE:  Printer names with spaces will NOT be accepted.  
::Usage: run addprinters and follow onscreen directions


cls
echo This script adds the specified local or network printer  
echo to the deafult account for all existing/new users.  
echo *IMPORTATNT* Printer names with spaces will NOT be accepted.
echo *******************************************************

SET /P target=Enter target computer name (this compupter)  
SET /P printer=Enter Printserver/Printername (do not include \\) 
echo Attempting to add %printer% for all users on %target%


rundll32 printui.dll,PrintUIEntry /ga /c\\%target% /n\\%printer%
echo New printers will NOT appear until spooler is restarted.
SET /P reset=Reset print spooler Y/N?     
if "%reset%"=="y" goto spooly
goto end

:spooly
start /wait sc \\%target% stop spooler
start /wait sc \\%target% start spooler
echo Print Spooler Service restarted.

:end

Simply save this text to a .cmd file and run it if you want to give it a try.

1
  • I am caught up with other issues at the moment so this project is on a back burner for now, I have not forgotten about your answer. When I have the time I will try it out. Thanks!
    – qroberts
    Jul 28, 2011 at 16:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .