Share a Windows Printer from the Command Line

Source: https://www.puryear-it.com/sharing-a-remote-windows-printer-from-the-command-line

We’ll be using pstools, rundll, and WMIC to do this.

Download the PsTools suite and extract Open a CMD window and change directory to the extracted PsTools location Start a CMD session on the remote machine using psexec:

    > psexec \remote-machine cmd
After connecting, list the printers available on the machine:
    > wmic printer get name

  Name
  printer1
  printer2
  \servernameprinter3

If you want to make printer1 above shared:

    > rundll32 printui.dll,PrintUIEntry /Xs /n "printer1" Sharename "Printer1"
    > rundll32 printui.dll,PrintUIEntry /q /Xs /n "printer1" Attributes Shared
Confirm the printer is available by going to \remote-machine in Windows Explorer; you should see the printer available now.

Last modified:: 2016/10/06 15:22