[VBS] Change Default Printer


/ Published in: Visual Basic

Change default printer with vbs script


Copy this code and paste it in your HTML
  1. strComputer = "."
  2. printer = "PRINTER_NAME"
  3.  
  4. Set objWMIService = GetObject("winmgmts:" _
  5. & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
  6.  
  7. Set colInstalledPrinters = objWMIService.ExecQuery _
  8. ("Select * from Win32_Printer Where Name = '" & printer & "'")
  9.  
  10. For Each objPrinter in colInstalledPrinters
  11. objPrinter.SetDefaultPrinter()
  12. msgbox "Printer Changed to:" & Chr(13) & Chr(13)_
  13. & printer, vbokonly + vbinformation, "Printers"
  14. Next

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.