Solved

delete printers from command line using wildcards

Posted on 2011-03-02
3
1,190 Views
Last Modified: 2012-08-13
I saw a solution in an older thread here:
http://www.experts-exchange.com/Hardware/Peripherals/Printers_Scanners/Q_23476195.html

Anyone know if you can use wildcards in those scripts? we are migrating a hundred or so workstations from one server to another, and need to delete all printers mapped to one server.  We will be using GPO deployed printers for the new ones.

So would something like this work?:


' Begin Code
Option Explicit
Dim objNetwork, strPrinter1
strPrinter1 = "\\server\*"

Set objNetwork = CreateObject("WScript.Network")
objNetwork.RemovePrinterConnection strPrinter1

Wscript.Quit
0
Comment
Question by:cameramonkey
3 Comments
 
LVL 32

Expert Comment

by:Rodney Barnhardt
ID: 35028138
0
 

Author Comment

by:cameramonkey
ID: 35029419
I see lots of deleting ALL printers or ALL NETWORK printers, but none that support the wildcard of any printers on a specific server. I'm trying to avoid enumerating all 25 or so printers on that decommissioned server and deleting them individually since ALL printers on that server need to go without touching any others.
0
 
LVL 11

Accepted Solution

by:
yelbaglf earned 125 total points
ID: 35030700
Try something like this...

strComputer = "."
i = 0

Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colPrinters =  objWMIService.ExecQuery _
    ("Select * from Win32_Printer")

For Each objPrinter in colPrinters
	
	ReDim Preserve arrPrinterName(i)
	arrPrinterName(i) = objPrinter.Name
		If InStr(arrPrinterName(i), oldServer) Then
			objNetwork.RemovePrinterConnection arrPrinterName(i)
			i=i+1
		
		Else
			
		End If
	
Next

Open in new window

0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

How to solve seemingly unsolvable printer issues. Users sometimes run into printing issues where all the normal steps do not seem to work. Well the steps below can show users how to take one extra step beyond the normal steps needed to remove old…
This seems to be a very common error related to the Samsung printer driver. First, this is the error we're talking about: Log: System Type: Error Event: 7000 Agent Time: 3:37:24 am 22-Apr-09 Event Time: 6:07:24 pm 21-Apr-09 UTC Source: Se…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now