Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help me write vbs code to remove printers

Status
Not open for further replies.
Dec 20, 2004
34
US
I know this subject have been talked about alot but here's the code I use to remove printers and it works if the printer is already installed. If it's not installed already, it gives error. How can I make a script that will remove any installed printer on a server, so that a user can run? I need this script to remove printers from an old server and add printers from new server.

Dim net
Set net = CreateObject("WScript.Network")
net.RemovePrinterConnection "\\oldserver\printer"

Dim net
Set net = CreateObject("WScript.Network")
net.AddWindowsPrinterConnection "\\newserver\printer
 
just put at the start
[coce]
on error resume next
[/code]

Although this question is more suited to the forum329 (vbscript) rather then the Vb6 forum which is different.
D

----------------------------------------
There are 2 types of computer, the prototype and the obsolete!!
----------------------------------------
No D, just plank - and its not my fault
 
Glad could help

D

----------------------------------------
There are 2 types of computer, the prototype and the obsolete!!
----------------------------------------
No D, just plank - and its not my fault
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top