?
Solved

Batch file to delete network printers and add new ones

Posted on 2011-09-02
4
Medium Priority
?
360 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 2000 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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

by Batuhan Cetin In this article I will be guiding through the process of removing a failed DC metadata from Active Directory (hereafter, AD) using the ntdsutil tool in a Windows Server 2003 environment. These steps are not necessary in a Win…
A quick step-by-step overview of installing and configuring Carbonite Server Backup.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses

770 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