Solved

Batch file to delete network printers and add new ones

Posted on 2011-09-02
4
353 Views
Last Modified: 2012-05-12
Hello everyone,

I hope this isn't a complicated question.  I need assistance with a .bat file that will do the following:

* scan the local machine that executes the .bat file for installed network printers from \\server1
* delete those printers
* use the same printer names to be reinstalled but from \\server2

both server (server1 and server2) are Win2k3 STD with all updates and patches installed.  All clients are Windows XP SP3 with all updates and patches installed as well.

Thank you,
0
Comment
Question by:bloodywicked
  • 2
4 Comments
 
LVL 7

Expert Comment

by:JohnGrunwell
Comment Utility
Try this

RUNDLL32 printui.dll,PrintUIEntry /n \\server1\printer-name /dn

repeat this line for all the old printers that are or maybe installed on the computer this will remove them

start \\server2\printer-name
repeat this line for all printers you want installed on the computer

look something like this then change your txt file to bat

RUNDLL32 printui.dll,PrintUIEntry /n \\server1\printer-name /dn
RUNDLL32 printui.dll,PrintUIEntry /n \\server1\printer-name /dn


start \\server2\printer-name
start \\server2\printer-name
start \\server2\printer-name
0
 

Author Comment

by:bloodywicked
Comment Utility
Hello John,

Thank you so much for the prompt response.  I'm familiar with RUNDLL32 printui.dll,PrintUIEntry command.  I was hoping for the batch script to scan the local machines that it runs on and find out if there're any printers mapped from the old server, and if so delete it and add it from the new server.

I guess can do that on a per line bases for all printers, however, we have well over 30 printers on multiple floors, and not everyone needs to be connected to every printer.

thank you
0
 
LVL 7

Expert Comment

by:JohnGrunwell
Comment Utility
create different batch files per area is what I've done in the past
0
 
LVL 2

Accepted Solution

by:
solocoyote earned 500 total points
Comment Utility
Here are the commands I have run in a script. Basically, I had entered one of the following commands per possible printer on the old server.

rundll32 printui.dll,PrintUIEntry /q /dn /n "\\dc1\HP9050"

Then I added the following line for each printer that I wanted the particular group/user to have mapped

rundll32 printui.dll,PrintUIEntry /q /in /n "\\dc2\HPLJ9050"

Please note I just deleted the reference from server dc1 to dc2.

I am sure one could write a better more elegant script to look at the installed network printers and then re-add the ones that are required, but i didn't have enough time to do so. Plus we made a decision that just because a user has access to a particular printer on the other side of the building doesn't mean 1.) They need and 2.) They could add it manually in the future.


0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This may not be a text book method to resolve VSS backup issues but it seemed to have worked on few of the Windows 2003 servers we had issues while performing a Volume Shadow Copy backup. If you have issues while performing a shadow copy backup usin…
On July 14th 2015, Windows Server 2003 will become End of Support, leaving hundreds of thousands of servers around the world that still run this 12 year old operating system vulnerable and potentially out of compliance in many organisations around t…
This video discusses moving either the default database or any database to a new volume.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now