[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Batch file to delete network printers and add new ones

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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Numerous times I have been asked this questions that what is it that makes my machine log on so slow, there have been cases where computers took 23 minute exactly after taking password and getting to the desktop. Interesting thing was the fact th…
Setting up a Microsoft WSUS update system is free relatively speaking if you have hard disk space and processor capacity.   However, WSUS can be a blessing and a curse. For example, there is nothing worse than approving updates and they just have…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

650 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