Salvare come .vbs
In questo caso verranno selezionate tutte le stampanti che contengono la parola "test" e "pippo" e verranno reindirizzate verso la lpt1.
Se vogliamo selezionare il nome esatto e non il nome contenuto possiamo usare la stringa DeviceID='test' al posto di DeviceID like '%test%'"
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colPrinters = objWMIService.ExecQuery _
("Select * From Win32_Printer Where DeviceID like '%test%'")
For Each objPrinter in colPrinters
objPrinter.PortName = "LPT1:"
objPrinter.Put_
Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colPrinters = objWMIService.ExecQuery _
("Select * From Win32_Printer Where DeviceID like '%pippo%'")
For Each objPrinter in colPrinters
objPrinter.PortName = "LPT1:"
objPrinter.Put_
Next
============================================================
============================================================
============================================================
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colPrinters = objWMIService.ExecQuery _
("Select * From Win32_Printer Where DeviceID like '%cuplaser%'")
For Each objPrinter in colPrinters
objPrinter.PortName = "client:0:cuplaser"
objPrinter.Put_
Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colPrinters = objWMIService.ExecQuery _
("Select * From Win32_Printer Where DeviceID like '%datamax%'")
For Each objPrinter in colPrinters
objPrinter.PortName = "client:0:datamax"
objPrinter.Put_
Next
Nessun commento:
Posta un commento
Lascia qui il tuo commento.