[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


how to map/unmap printers using a batch file.

Posted on 2008-11-11
Medium Priority
Last Modified: 2012-05-05
hi all,

just a quick one.

i am trying to map and unmap printers using a batch file. i cant find any info on this so could someone point me in the right direction!

rundll32 printui.dll,PrintUIEntry /q /gd /n\\printscanserver\transport laser

this doesnt work for unmapping the printer!

can i do anything else that i can add into my batch file?

Question by:Goption
LVL 13

Assisted Solution

leegclystvale earned 800 total points
ID: 22932168
create a batch file and call it printers.bat (or anything!)

START \\servername\Printername1
START \\servername\Printername2

Copy file to a share on a server and then add a line in the logon scripts to run the batch file.

login script

net use M: \\ServerName\Sharename
LVL 57

Expert Comment

by:Pete Long
ID: 22932169

Use Con2prt
Rem ** Example Printers.bat file **
Rem ** Adds network printers to Windows NT/2000/XP clients**
Rem    To be run from the login script via "call \\server1\share\printers.bat" command.
Rem    The &Location% environment variable is machine specific and needs to be defined manually on each machine
Rem    either via Control Panel | System | Advanced | Environment Variables | System Variables
Rem    or by creating the following String registry key on each machine:
Rem      [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment]
Rem      "Location"="Room23"
\\server1\share\CON2PRT /F
IF %Location% == Room23 \\server1\share\CON2PRT /CD \\dc1\Room23
IF %Location% == Room23 \\server2\share\CON2PRT /C \\dc1\Room43
/CD = Connect and make default
/C = Connect only

LVL 85

Accepted Solution

oBdA earned 1200 total points
ID: 22932555
If you insist on rundll32, try "/dn" instead of "/gd", and put share names containing spaces in quotes:
rundll32 printui.dll,PrintUIEntry /q /dn /n "\\printscanserver\transport laser"

And as much as I used to love con2prt.exe, it's pretty hard to find nowadays, as it was part of the NT4 Zero Administration Kit; this website is long since dead.
As replacement, there are a bunch of printer management VB scripts (try "dir p*.vbs") in the %systemroot%\system32 folder. These are better suited for logon scripts than rundll32, because they're not GUI oriented. The one you need is prnmngr.vbs:
cscript prnmngr.vbs /?
will give you some examples for usage.

Author Closing Comment

ID: 31515591
thanks for your help it worked a treat!

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You might have come across a situation when you have Exchange 2013 server in two different sites (Production and DR). After adding the Database copy in ECP console it displays Database copy status unknown for the DR exchange server. Issue is strange…
For anyone that has accidentally used newSID with Server 2008 R2 (like I did) and hasn't been able to get the server running again because you were unlucky (as I was) and had no backups - I was able to get things working by doing a Registry Hive rec…
This tutorial will walk an individual through setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Suggested Courses

873 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