Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2352
  • Last Modified:

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 :)
0
Trihimbulus
Asked:
Trihimbulus
1 Solution
 
solomonacquahCommented:
'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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now