none
wmic class win32_printer call AddPrinterConnection("\\server\printer") RRS feed

  • General discussion

  • Just trying to get something like this to work:

    wmic class win32_printer call AddPrinterConnection("\\server\printer")

    It keeps saying

    ReturnValue = 1801;

    I've tried single quotes and twice as many backslashes.  Is there some other special way to quote it?


    • Edited by JS2010 Tuesday, April 17, 2018 4:23 PM
    • Changed type Bill_Stewart Friday, July 27, 2018 4:15 PM
    • Moved by Bill_Stewart Friday, July 27, 2018 4:15 PM User should use GPO preferences
    Tuesday, April 17, 2018 4:22 PM

All replies

  • I would recommend configuring printers for users using GPO preferences rather than a script.

    -- Bill Stewart [Bill_Stewart]

    Tuesday, April 17, 2018 4:23 PM
  • WMIC is not a script.

    For WMI return code you can look them uo:

    https://msdn.microsoft.com/en-us/library/aa384769(v=vs.85).aspx


    \_(ツ)_/

    Tuesday, April 17, 2018 4:29 PM
  • With new profiles?  I find GPO preferences unreliable for this.

    Tuesday, April 17, 2018 5:20 PM
  • Sounds like you need to do some GPO troubleshooting. That's not a topic for this forum.

    -- Bill Stewart [Bill_Stewart]

    Tuesday, April 17, 2018 6:17 PM
  • It works at the powershell prompt, but not the cmd prompt.  Quoting issues?

    Tuesday, April 17, 2018 7:04 PM
  • 1) We don't use wmic in PowerShell but rather Get-WmiObject, etc.

    2) This is not the right place to ask about command-line commands such as wmic.

    3) I refer the honorable gentleman to my previous replies.


    -- Bill Stewart [Bill_Stewart]

    Tuesday, April 17, 2018 7:28 PM
  • You are correct.  It works from PowerShell but not at a CMD prompt.  The issue is repeatable on Windows 7 and possibly later.  Others have logged issues with this.

    As suggested by Bill you should be assigning printers via GP Printer policy.  It manages printers correctly and has no issues when GP is working correctly.


    \_(ツ)_/


    • Edited by jrv Tuesday, April 17, 2018 7:31 PM
    Tuesday, April 17, 2018 7:30 PM
  • This call method works correctly for poth PS and CMD:

     wmic printer call AddPrinterConnection "\\sbs01\Kyocera ECOSYS M3550idn KX"


    \_(ツ)_/

    Tuesday, April 17, 2018 7:37 PM