• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1121
  • Last Modified:

how to map/unmap printers using a batch file.

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?

thanks
0
Goption
Asked:
Goption
2 Solutions
 
leegclystvaleCommented:
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
\\Servername\sharename\printers.bat
0
 
Pete LongTechnical ConsultantCommented:

Use Con2prt
e.g.
@ECHO OFF
 
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
 
 
 
Note
/CD = Connect and make default
/C = Connect only
 


 
0
 
oBdACommented:
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.
0
 
GoptionAuthor Commented:
thanks for your help it worked a treat!
0
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.

Join & Write a Comment

Featured Post

Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now