VB Script to remove local printer and network printer

I need a script that will delete two printers on each workstation. One of the printers is a local printer named PIK 7000. With this, I also need it's associated custom port deleted which is named PIK 0. Also, I need all associated drivers removed. These drivers are primarily located in the below locations:

del /F /Q C:\Windows\System32\Spool\Drivers\W32x86\ka*.*
del /F /Q C:\Windows\System32\Spool\Drivers\W32x86\ki*.*
del /F /Q C:\Windows\System32\Spool\Drivers\W32x86\ku*.*
del /F /Q C:\Windows\System32\Spool\Drivers\W32x86\2\ka*.*
del /F /Q C:\Windows\System32\Spool\Drivers\W32x86\2\ki*.*
del /F /Q C:\Windows\System32\Spool\Drivers\W32x86\2\ku*.*
del /F /Q C:\Windows\System32\Spool\Drivers\W32x86\2\temp\ka*.*
del /F /Q C:\Windows\System32\Spool\Drivers\W32x86\2\temp\ki*.*
del /F /Q C:\Windows\System32\Spool\Drivers\W32x86\2\temp\ku*.*
del /F /Q C:\Windows\System32\Spool\Drivers\W32x86\3\ka*.*
del /F /Q C:\Windows\System32\Spool\Drivers\W32x86\3\ki*.*
del /F /Q C:\Windows\System32\Spool\Drivers\W32x86\3\ku*.*
del /F /Q C:\Windows\System32\Spool\Drivers\W32x86\3\temp\ka*.*
del /F /Q C:\Windows\System32\Spool\Drivers\W32x86\3\temp\ki*.*
del /F /Q C:\Windows\System32\Spool\Drivers\W32x86\3\temp\ku*.*
del /F /Q C:\Windows\System32\kaw2kppm.dll
del /F /Q C:\Windows\System32\kuwxppm.dll

** One side note - after deleting the files above, the driver still show up in Printers and Faxes > Server Properties > Drivers.

The other printer I need to be deleted from each workstation (in the same script) is named Plotter PIK 7000. This is a network printer and the UNC path is \\printserver\Plotter PIK 7000.

*** Side note - is there a way to target any associated drivers to be deleted?

Lastly I need the following registry key to be deleted from each workstation in this same script:

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Monitors\PIKMonitor]

Let the battle Begin :)
TrihimbulusAsked:
Who is Participating?
 
solomonacquahConnect With a Mentor Commented:
'remove all local printers

'change false to true for network printer
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
 
Set colInstalledPrinters =  objWMIService.ExecQuery _
    ("Select * from Win32_Printer Where Network = FALSE")
 
For Each objPrinter in colInstalledPrinters
    objPrinter.Delete_
Next

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.