How does "net use" work in windows 7 for printer connection?

28,399

Solution 1

From ss64:

"NET USE command can map a network printer to an LPT port (for DOS type applications that print to a port.) but this does not add the printer to the Control Panel GUI."


If you're limited to using cmd, you might want to use Rundll32 printui.dll,PrintUIEntry.

If you can use PowerShell, you can do something like this:

$prnt = [wmiclass]"Win32_Printer"
$prnt.AddPrinterConnection("\\PrintServer\PrintShare")

Solution 2

When you are using cmd - net use command you won't get Printer in your Devices and printers. This command is good for MS DOS based applications to print on LPT port even if your PC doesn't have any. Sometimes even you have installed USB printer you simply can't print through MS DOS apps and that is scenario where you use this way to map your Printer on a LPT port.

On this post I have explained how to use this command in Local Network with a PC running Win 7 and other running Win XP

Share:
28,399

Related videos on Youtube

oz123
Author by

oz123

I am a Software Engineer usually working as DevOps or Back-End developer. I feel comfortable using various Linux distributions (usually at work I have Debian\Ubuntu\Red Hat\CentOS and even {Open,}SuSE. Whenever I can, I use Gentoo and NetBSD). My tools of choice are Python and C. Take a look at my CLI framework for Python.

Updated on September 18, 2022

Comments

  • oz123
    oz123 almost 2 years

    I've been using "net use" successfully to connect to shared drives on my network with Windows 7. Now, I am trying to connect a Windows 7 computer to a shared printer on a windows 7.

    So, on the client computer I've done through it the GUI to see everything works properly. Than, I disconnected the printer and tried using the command line to do the same thing like this:

    net use \\FRONTPC\FCPrinter 
    

    it says:

    The command completed successfuly.
    

    However I don't see the printer under "Devices and Printers". So, where is the printer? What am I doing wrong?

  • oz123
    oz123 over 12 years
    thanks, that looks useful, but I'm still not getting the awkward syntax of the printui.dll command... can you explain?
  • MDMarra
    MDMarra over 12 years
    Something like RUNDLL32 PRINTUI.DLL,PrintUIEntry /ga /n\\PrintServer\PrintShare should work. There's a good outline with examples here
  • oz123
    oz123 over 12 years
    I managed to "add" the printer using powershell. However... The print test page fails ... And, I know it works using the gui... So there is still one more step missing...Maybe it's the driver ?
  • MDMarra
    MDMarra over 12 years
    @Oz123 I have that exact code in a larger script that successfully maps printers for hundreds of computers without issue.
  • oz123
    oz123 over 12 years
    I guess it is is a driver issue ... On another printer the return code was 0, so the printer did succeed with printing a test page. However with the faulty printer the error code was 1797...
  • oz123
    oz123 over 12 years
    I believe you :-) However, I am a Linux admin, who's been thrown to the sharks. I have to admin windows now... and everything is new... How do I know what is a 1797 error???
  • MDMarra
    MDMarra over 12 years
    @Oz123 A quick Google search shows that it usually occurs when the driver fails to install for some reason. If this allows you to map most printers, you should accept the answer. If you continue to have an issue with a specific printer, you should open a new detailed question that includes the method of mapping and any error logs that you find. As a new Windows admin, I think you'll enjoy PowerShell. It's the closest thing that we have to bash.