[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2011-02-18
8
Medium Priority
?
4,790 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
New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

 

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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

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 Migration Tip #1 – Source Server Health can be found here: http://www.experts-exchang…
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…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

656 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