Skip to content

Instantly share code, notes, and snippets.

@gioxx gioxx/Stampanti.vbs
Created May 13, 2019

Embed
What would you like to do?
Pulisci le code di stampa vecchie tenendo al sicuro quelle (spesso) virtuali dedicate ad altri mestieri che continuano invece a essere utili (ed evidentemente utilizzate). Dai un'occhiata all'articolo per saperne di più: https://wp.me/pdQ5q-akh
'==========================================================================
'
' Connessioni stampanti
' GSolone 2019
' Ult. mod. 6/5/19
' Credits:
' https://devblogs.microsoft.com/scripting/how-can-i-remove-all-the-local-printers-from-a-computer/
' https://stackoverflow.com/questions/15424589/open-control-panel-using-vbscript
' https://stackoverflow.com/questions/1686454/run-a-vbscript-from-another-vbscript
'
'==========================================================================
ON ERROR RESUME NEXT
' Rimozione stampanti locali
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_Printer Where Network = FALSE")
For Each objPrinter in colInstalledPrinters
If objPrinter.Name = "Adobe PDF" Or objPrinter.Name = "Fax" Or objPrinter.Name = "Microsoft Print to PDF" Or objPrinter.Name = "Microsoft XPS Document Writer" Or objPrinter.Name = "OneNote" Or objPrinter.Name = "PDFCreator" Or objPrinter.Name = "Send To OneNote 2016" Or objPrinter.Name = "WebEx Document Loader" Then
' Non rimuovo la stampante
Else
' Rimuovo la stampante
objPrinter.Delete_
End If
Next
' Stampanti della sede
wshnet.AddWindowsPrinterConnection "\\SERVERSTAMPANTI\STAMPANTE01"
wshnet.AddWindowsPrinterConnection "\\SERVERSTAMPANTI\STAMPANTE02"
wshnet.AddWindowsPrinterConnection "\\SERVERSTAMPANTI\STAMPANTE03"
MsgBox "Dovrai ora scegliere la tua stampante predefinita" & vbCrLf & vbCrLf & "Fai clic con il tasto destro sul nome della stampante che ti interessa, poi seleziona Imposta come stampante predefinita",vbInformation,"Imposta stampante predefinita"
CreateObject("WScript.Shell").Run "control.exe printers"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.