Set wshNetwork = CreateObject("WScript.Network")
Set wshShell = CreateObject("WScript.Shell")
blnPrinterSet = False
strPrinterSet = wshSHell.RegRead("HKCU\Software\LoginScript\PrinterSet")
If Len(strPrinterSet) > 0 Then
blnPrinterSet = True
Else
wshShell.RegWrite "HKCU\Software\LoginScript\PrinterSet", "1"
End If
If not blnPrinterSet Then
'Remove ALL old printers
'Enumerate all printers first, after that you can select the printers you want by performing some string checks
Set WSHPrinters = WSHNetwork.EnumPrinterConnections
For LOOP_COUNTER = 0 To WSHPrinters.Count - 1 Step 2
'To remove only networked printers use this If Statement
If Left(WSHPrinters.Item(LOOP_COUNTER + 1), 2) = "\\" Then
If WSHPrinters.Item(LOOP_COUNTER + 1) <> "" then
WSHNetwork.RemovePrinterConnection WSHPrinters.Item(LOOP_COUNTER + 1), True, True
End IF
End If
Next
'Install Printers
WSHNetwork.AddWindowsPrinterConnection strUNCToPrinter
End If
|