education-dynamics
asked on
VB script remove network printers wild card
Hi Expert People,
I have a remove network printer script here, but I have about 30 different printer names. Anyone know how to write a wild card to replace the printername.
Set objNetwork = CreateObject("Wscript.Netw ork")
objNetwork.RemovePrinterCo nnection "\\servername\printername"
Or maybe something like this:
Printername = printer1
printername = printer2
printername = printer3
and so on...
Thank you for all your help!
I have a remove network printer script here, but I have about 30 different printer names. Anyone know how to write a wild card to replace the printername.
Set objNetwork = CreateObject("Wscript.Netw
objNetwork.RemovePrinterCo
Or maybe something like this:
Printername = printer1
printername = printer2
printername = printer3
and so on...
Thank you for all your help!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Set WshNetwork = CreateObject("WScript.Netw ork")
rem ** This will delete existing printers **
On Error Resume Next
Set oPrinters = WshNetwork.EnumPrinterConn ections
For i = 1 to oPrinters.Count - 1 Step 2
WshNetwork.RemovePrinterCo nnection oPrinters.Item(i)
Next
'The above will just remove any installed printers.
If you need anything else please post back.
rem ** This will delete existing printers **
On Error Resume Next
Set oPrinters = WshNetwork.EnumPrinterConn
For i = 1 to oPrinters.Count - 1 Step 2
WshNetwork.RemovePrinterCo
Next
'The above will just remove any installed printers.
If you need anything else please post back.
ASKER
I don't know what arrays are but I have printers such as these listed below. Any script that would add all these under one script that would be great!
The shorter the script the better--it's just more cleaner and easier to understand.
\\svrprinter1\LA-2200
\\svrprinter1\palm1-2200
\\svrprinter1\accounting-2 200
\\svrprinter1\hr-2200
I apologize for the response.
The shorter the script the better--it's just more cleaner and easier to understand.
\\svrprinter1\LA-2200
\\svrprinter1\palm1-2200
\\svrprinter1\accounting-2
\\svrprinter1\hr-2200
I apologize for the response.
We could make an array of printers and make it remove each printer that is stored in the array.