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?
tigermattConnect With a Mentor Commented:

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


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.
I like this bat files, however what can we add to this bat files to make this network printer become the default
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.