How do I map Network printers using a .bat file?

Posted on 2008-11-10
Last Modified: 2013-12-15
I need to creat a .BAT file that will install all the printers on the server. It needs to deslete its self once it completes the install. The .BAT file should use the Net Use command.

Question by:Ephraim-Sturrup
    LVL 58

    Expert Comment


    The method at the command line for mapping printers is for legacy DOS applications since it will map a printer to an LPTx port, but won't add the printer to Windows' Control Panel > Printers area.

    A better way to map printers would be a VBS script, which does add the printers to the Printers folder (and allow you to use them from your applications). The script below can be used to start with and you can add more printer connections as necessary.

    'tigermatt's script
    'Copy to Notepad, set printer share(s), File > Save, Files of Type: Pick 'All Files', enter "map_printer.vbs" with the quotes.
    Set objNetwork = CreateObject("WScript.Network")
    'Copy and paste this line and change the printer path to add more printer connections
    objNetwork.AddWindowsPrinterConnection "\\server\Printer Share"

    Open in new window


    Author Comment

    Please send me an example.
    LVL 58

    Accepted Solution


    The script posted at the bottom of my last comment is an example of mapping printers using a VBS script. The VBS approach is tidier, however if you require a BAT file approach, the below should do the trick. You need to change the name of the server hosting the print queue, and the name of the print queue itself.

    rem Map a Printer
    RunDll32.EXE printui.dll,PrintUIEntry /in /n \\server\printer

    Open in new window


    Expert Comment

    I like this bat files, however what can we add to this bat files to make this network printer become the default

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    You have seen this as an option on your internet browser before or it may be completely new to you.  But what does this mean and why would I use this?
    Skype is a P2P (Peer to Peer) instant messaging and VOIP (Voice over IP) service – as well as a whole lot more.
    The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…
    The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now