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

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.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


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

Ephraim-SturrupAuthor Commented:
Please send me an example.

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


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
I like this bat files, however what can we add to this bat files to make this network printer become the default
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Printers and Scanners

From novice to tech pro — start learning today.