I have a script to delete printers on our workstations (they are network printers but were initially set up on Win 2000 workstations with a local port..\\server\printer).
I have figured out how to delete all printers on a workstation, but need to keep the printers connected to LPT1, so I have a script that will delete only the local ports I specify. It works great on our Win XP machines; however, it doesn't work on Win 2000.(line 20 char 5.."provider is not capable of the attempted operation"..80041024...swbemobject)...
Any thoughts?
Thanks
'this will delete printers setup with a local port (\\srh-nt4\mis)...replace "deviceID = '' with
'printer name from corresponding .txt file in \\srh-nt1\srhlogon$\unison\printers..Must also add full
'string for each printer to be deleted.
'*************************************************************************************************
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_Printer where DeviceID = 'HP LaserJet 4000 Series PCL 5'")
For Each objPrinter in colInstalledPrinters
objPrinter.Delete_
Next
Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_Printer where DeviceID = 'HP LaserJet 2100 (Copy 2)'")
For Each objPrinter in colInstalledPrinters
objPrinter.Delete_
Next
Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_Printer where DeviceID = 'HP LaserJet 2100'")
For Each objPrinter in colInstalledPrinters
objPrinter.Delete_
Next
I have figured out how to delete all printers on a workstation, but need to keep the printers connected to LPT1, so I have a script that will delete only the local ports I specify. It works great on our Win XP machines; however, it doesn't work on Win 2000.(line 20 char 5.."provider is not capable of the attempted operation"..80041024...swbemobject)...
Any thoughts?
Thanks
'this will delete printers setup with a local port (\\srh-nt4\mis)...replace "deviceID = '' with
'printer name from corresponding .txt file in \\srh-nt1\srhlogon$\unison\printers..Must also add full
'string for each printer to be deleted.
'*************************************************************************************************
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_Printer where DeviceID = 'HP LaserJet 4000 Series PCL 5'")
For Each objPrinter in colInstalledPrinters
objPrinter.Delete_
Next
Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_Printer where DeviceID = 'HP LaserJet 2100 (Copy 2)'")
For Each objPrinter in colInstalledPrinters
objPrinter.Delete_
Next
Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_Printer where DeviceID = 'HP LaserJet 2100'")
For Each objPrinter in colInstalledPrinters
objPrinter.Delete_
Next