none
BGINFO to query default printer RRS feed

  • Question

  • Hey, I was wondering if there is a way to display the current default printer for win10 devices?

    thanks

    Wednesday, February 19, 2020 4:34 PM

Answers

  • Create a WMI query in a script that output the Default printer name..

    On Error Resume Next
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set colInstalledPrinters =  objWMIService.ExecQuery ("Select * from Win32_Printer Where Default = True")
    For Each objPrinter in colInstalledPrinters
         Echo objPrinter.Name
    Next

    And then use it in BGINFO

    HTH
    -mario


    • Edited by mariora_ Thursday, February 20, 2020 7:53 AM corrected code
    • Proposed as answer by mariora_ Thursday, February 20, 2020 7:54 AM
    • Marked as answer by srm11671Mo Thursday, February 20, 2020 7:02 PM
    Wednesday, February 19, 2020 5:10 PM
  • in a script? for BGINFO?

    sorry guess I am not following that

    • Marked as answer by srm11671Mo Thursday, February 20, 2020 7:02 PM
    Thursday, February 20, 2020 2:24 PM
  • Save the code i posted to a vbs file, let's say c:\temp\GetDefPrint.vbs and eventually test it to see if it works as expected..

    then start BGinfo. Click on the Custom button and then New..

    Call your new custom field "Default Printer", select the vbscript option button, Browse for the saved vbscript file and finally press Ok

    Now select the new value in the list.. and Preview it..

    That's all..

    HTH
    -mario

    • Marked as answer by srm11671Mo Thursday, February 20, 2020 7:01 PM
    Thursday, February 20, 2020 4:23 PM

All replies

  • Create a WMI query in a script that output the Default printer name..

    On Error Resume Next
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set colInstalledPrinters =  objWMIService.ExecQuery ("Select * from Win32_Printer Where Default = True")
    For Each objPrinter in colInstalledPrinters
         Echo objPrinter.Name
    Next

    And then use it in BGINFO

    HTH
    -mario


    • Edited by mariora_ Thursday, February 20, 2020 7:53 AM corrected code
    • Proposed as answer by mariora_ Thursday, February 20, 2020 7:54 AM
    • Marked as answer by srm11671Mo Thursday, February 20, 2020 7:02 PM
    Wednesday, February 19, 2020 5:10 PM
  • in a script? for BGINFO?

    sorry guess I am not following that

    • Marked as answer by srm11671Mo Thursday, February 20, 2020 7:02 PM
    Thursday, February 20, 2020 2:24 PM
  • Save the code i posted to a vbs file, let's say c:\temp\GetDefPrint.vbs and eventually test it to see if it works as expected..

    then start BGinfo. Click on the Custom button and then New..

    Call your new custom field "Default Printer", select the vbscript option button, Browse for the saved vbscript file and finally press Ok

    Now select the new value in the list.. and Preview it..

    That's all..

    HTH
    -mario

    • Marked as answer by srm11671Mo Thursday, February 20, 2020 7:01 PM
    Thursday, February 20, 2020 4:23 PM
  • ah.. Awesome thank You!!!

    very cool!!

    • Marked as answer by srm11671Mo Thursday, February 20, 2020 7:01 PM
    • Unmarked as answer by srm11671Mo Thursday, February 20, 2020 7:02 PM
    Thursday, February 20, 2020 7:01 PM
  • hey i have another question if yo dont mind, do you know how to query default printer from Virtual Machine?

    Thursday, February 20, 2020 9:18 PM