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
LVL 1
GoptionAsked:
Who is Participating?

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

x
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.

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

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

From novice to tech pro — start learning today.