Solved

Batch file to delete network printers and add new ones

Posted on 2011-09-02
4
358 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 7

Expert Comment

by:JohnGrunwell
ID: 36474568
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
ID: 36474602
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
ID: 36474610
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
ID: 36475077
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've always wanted to allow a user to have a printer no matter where they login. The steps below will show you how to achieve just that. In this Article I'll show how to deploy printers automatically with group policy and then using security fil…
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

688 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