Solved

Add network printers using a login script

Posted on 2003-11-27
7
21,417 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 85

Accepted Solution

by:
oBdA earned 250 total points
ID: 9830364
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
ID: 9830377
thanks for quick reply, I shall give this a try.
0
 
LVL 57

Expert Comment

by:Pete Long
ID: 9830402

*****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
Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

 

Expert Comment

by:wozza_c
ID: 9830430
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
ID: 9831665
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
ID: 10999552
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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

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…
There are times when we need to generate a report on the inbox rules, where users have set up forwarding externally in their mailbox. In this article, I will be sharing a script I wrote to generate the report in CSV format.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

695 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