?
Solved

VBScript - check if printer exists; delete old queue; install new queue

Posted on 2011-02-18
8
Medium Priority
?
4,757 Views
Last Modified: 2012-05-11
I will be migrating print queues to a new Windows 2003 Server next week and need a script that will:
Check the network printers currently installed on a PC (enumPrinterConnections)
against a list of print queues that will be moved to the new server
If the PC has a queue that will be moved, delete the current queue and install the new queue
If the PC does not have the queue that will be moved, do nothing and continue to check the next printer (without invoking an error message.) There are 9 queues that will be moved but not all PCs have every queue installed. There is a logon script which is a .bat file but I think a .vbs script can be called from it.

Adding and removing is simple enough:
'Remove a specific printer
WSHNetwork.RemovePrinterConnection PrinterPathDel
'Install A Printer
WSHNetwork.AddWindowsPrinterConnection PrinterPathAdd

but looping through both lists (currently installed and new queues to add)
is a little beyond me. I not sure how to use IF statements in this situation either.
0
Comment
Question by:bstillion
[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
  • 5
  • 2
8 Comments
 
LVL 65

Accepted Solution

by:
RobSampson earned 2000 total points
ID: 34935528
Hi, I have used the script shown here:
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_22955704.html

to remap printers from one server to another.  The arrPrinterShares array is where you place your oldprintername and your newprintername, and it should map those, and log the results.

Regards,

Rob.
0
 
LVL 1

Expert Comment

by:MarkThomasLee
ID: 34935949
I've had pretty good luck using snip its of the code from the following site:
Connecting Drive Letters:
http://computerperformance.co.uk/Logon/Logon_HomeDirAdv.htm 

Connecting, setting defaults and removing printers
http://computerperformance.co.uk/Logon/LogonScript_Printer.htm

Good luck!
m
0
 

Author Comment

by:bstillion
ID: 34944836
I adapting your suggestion Rob. I'll know by the end of the day and will respond back.

Brad
0
Python: Series & Data Frames With Pandas

Learn the basics of Python’s pandas library of series & data frames and how we can use these tools for data manipulation.

 

Author Comment

by:bstillion
ID: 34945090
Thanks Rob!
As always, your script is exactly what I needed.

I used the 2nd version without IP Filtering. The log it creates is great for monitoring
what happens and when.
During testing I discovered 7 queues that were duplicated on another server so it
also helped me clean up the newly acquired organization that has not had dedicated
IT support for too long.

Thanks again for your excellent (and fast!) solution!

Brad
0
 

Author Closing Comment

by:bstillion
ID: 34945097
Your VBScripts are great and get me motivated to learn more.
Thanks!

Brad
0
 

Author Comment

by:bstillion
ID: 34945303
Note:
In the array with old and new printer queues, I had to identify the
printers by display name rather than share name.
Took me some time to discover that so I wanted to save future users of this script some time.

Brad
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 34946600
Hi, thanks for that, I'm glad it helped.  Yeah, I think I noticed that it was display name after someone else tried it out.  The reason I didn't pick up on it was because we always have the display and share name identical.

Regards,

Rob.
0
 

Author Comment

by:bstillion
ID: 34953794
...It maintains the default printer too!

Brad
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Welcome to my series of short tips on migrations. Whilst based on Microsoft migrations the same principles can be applied to any type of migration. My first tip is around source server preparation. No migration is an easy migration, there is a…
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Suggested Courses

765 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