Quantcast
Viewing all articles
Browse latest Browse all 3098

VBS Script to remove local printers

Hello, I have been creating a VBS script to first remove printers and then add them. The problem is that some workstations have added the printers manual on local port.

How do I remove local port printers without knowing anything about them like an IP or name? Is there just a simple line for or.....???

Here is the script I made:

Text
Dim strComputer,strIPAddress,strIPRangeDim objNetworkDim IPConfigSet, IPConfigDim arrIPAddressSub RemovePrinters(strSearch) Set oNetwork = CreateObject("WScript.Network") strComputer = oNetwork.ComputerName Set oWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colInstalledPrinters = oWMIService.ExecQuery("Select * from Win32_Printer") For Each oPrinter in colInstalledPrinters If InStr(UCase(oPrinter.Name), UCase(strSearch)) > 0 Then oPrinter.Delete_ End...

Viewing all articles
Browse latest Browse all 3098

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>