Solved

Batch file to delete network printers and add new ones

Posted on 2011-09-02
4
355 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
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

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…
Learn about cloud computing and its benefits for small business owners.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

776 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