Solved

Add network printers using a login script

Posted on 2003-11-27
7
21,384 Views
Last Modified: 2010-04-14
I regularly set up Windows 2000/2003 Servers and usually with several network printers, but we came up against a problem recently on an install. We had about 15 printers running of various print servers and about 30 machines. We were able to set up the mapped drives fine using a bunch of net use x: \\server\folder 's but we couldnt work out a way of doing somthing similar with printers. IE when someone logs onto the machine it makes sure the printers are installed.

Would save me a hell of a lot of time if there was a way to do this
0
Comment
Question by:Ben_Gillam
7 Comments
 
LVL 82

Accepted Solution

by:
oBdA earned 250 total points
Comment Utility
The easiest way to do this is con2prt.exe from the NT4 Zero Administration Kit (still works fine under XP ;).
To map printers (or drives) based on group membership, you can use ifmember.exe from the W2k Resource Kit. If you don't have the Resource Kit, you can download ifmember here: http://www.microsoft.com/windows2000/techinfo/reskit/tools/new/ifmember-o.asp

Zero Administration Kit
http://www.microsoft.com/ntworkstation/downloads/Recommended/Featured/NTZAK.asp

To map a network printer:
con2prt.exe /c \\PrintServer\PrintShare
("/cd \\printserver\share" to install it as default printer; /f to delete all existing connections)

How to Use Con2prt.exe to Connect to a Network Printer
http://support.microsoft.com/?kbid=181663

A script solution could then, for example, look like this:

====8<----[Logon.cmd sample]----
ifmember.exe YourDomain\Group01
:: *** ifmember returns errorlevel 1 if the user *is* group member!
if not errorlevel 1 goto EndGroup01
net use X: \\FileServer\Group01Share
con2prt.exe /c \\PrintServer\Group01Printer
:EndGroup01
:: ...
====8<----[Logon.cmd sample]----
0
 

Author Comment

by:Ben_Gillam
Comment Utility
thanks for quick reply, I shall give this a try.
0
 
LVL 57

Expert Comment

by:Pete Long
Comment Utility

*****Printers*****

You are mapping an "lpt" port (Line Printer Terminal) All the rules above apply so the full command is,

net use lpt1 \\machinename\sharename\ /user:username password /Y

Zero Administration Kit
http://www.microsoft.com/ntworkstation/downloads/Recommended/Featured/NTZAK.asp

How to Use Con2prt.exe to Connect to a Network Printer
http://support.microsoft.com/?kbid=181663


Pete
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Expert Comment

by:wozza_c
Comment Utility
Hi Ben

In my environment we put a 'Call' command in the login script that calls a file that contains the con2prt command. An example of this Call command is;

CALL "%logonserver%\netlogon\printers\%computername%.CMD

This way you can set up a file for each machine by their computername. An example of what this file contains is;

con2prt /cd \\<printserver name and path>\<Printer Name>

Note that the d in the /cd makes the printer a default printer whereas /c will just add it.

The con2prt command is available at;

http://www.microsoft.com/ntworkstation/downloads/Recommended/Featured/NTZAK.asp

Hope that this is of some assistance.
0
 
LVL 1

Expert Comment

by:msavin
Comment Utility
hi
this may be what you are after

rundll32 printui.dll,PrintUIEntry /in /n \\yourprintserver\printer 1
rundll32 printui.dll,PrintUIEntry /y /n "printer"      

this will install whatever printers and second line will set a default

0
 

Expert Comment

by:chenglan
Comment Utility
I was using con2prt.exe but I have changed since I want more control now. You can use Windows Scripting Host and do something like this:

Set oNet = CreateObject("WScript.Network")
Set oArgs = Wscript.Arguments
printer = oArgs(0)
oNet.AddWindowsPrinterConnection printer

Then, have your login script (.cmd) call "wshFile.vbs \\server\printshare".

There are other functions for the WScript.Network Object (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/wsobjwshnetwork.asp) that you should check out for removing or enumerating printers.

I am just starting to use this method, but it looks quite nice. The power of control is not in the functions, but in the scripting now.

Chris
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Suggested Solutions

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
Find out what Office 365 Transport Rules are, how they work and their limitations managing Office 365 signatures.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now